首届比赛,作为学长带队去打比赛,压力可想而知,以保铜争银作为比赛的目标,最后打铁回来。。。
有可能是一辈子的遗憾了,因为下个赛季的ccpc的时候,我已经大四了,真的还有激情活力为了心中的梦想再战斗一年吗?
-----------------------------------------------------------------------
有学弟学妹一起玩耍确实很开心,很逗,省赛的时候虽然人多,但是完全放不开去玩,开心的事,总会过得太快,而那些遗憾,总会记得在心里
鼓足勇气,在北京和上海两站之前,重整心态,继续出发
-----------------------------------------------------------------------
开始分析题目了(正赛):这次比赛得到了一个真理:铜牌比手速,银牌比DP,金牌。。。我这种水平暂时也达不到。。。希望有一天吧
题目链接:5540--5551
http://acm.hdu.edu.cn/showproblem.php?pid=5540
A题:题意很简单,问两个2*2的矩阵,经过四种类型的旋转之后,会不会有某种可能的旋转使其全等
思路:暴力旋转模拟判断即可
bool check(){
    for(int i=1;i<=4;i++)
        if (num1[i]!=num2[i]) return false;
    return true;
}
int main(){
	scanf("%d",&t);
	for(int Case=1;Case<=t;Case++){
		for(int i=1;i<=4;i++) scanf("%d",&num1[i]);
		for(int i=1;i<=4;i++) scanf("%d",&num2[i]);
		int flag=0,tmp;
		if (check()) flag=1;
		tmp=num1[1];num1[1]=num1[2];num1[2]=num1[4];num1[4]=num1[3];num1[3]=tmp;
		if (check()) flag=1;
		tmp=num1[1];num1[1]=num1[2];num1[2]=num1[4];num1[4]=num1[3];num1[3]=tmp;
		if (check()) flag=1;
		tmp=num1[1];num1[1]=num1[2];num1[2]=num1[4];num1[4]=num1[3];num1[3]=tmp;
		if (check()) flag=1;
		tmp=num1[1];num1[1]=num1[2];num1[2]=num1[4];num1[4]=num1[3];num1[3]=tmp;
		if (check()) flag=1;
		if (flag)
			printf("Case #%d: POSSIBLE\n",Case);
		else
			printf("Case #%d: IMPOSSIBLE\n",Case);
	}
	return 0;
} http://acm.hdu.edu.cn/showproblem.php?pid=5546
G题:卡我的铜牌题!!!!!!!从第54分钟出了H之后,195分钟才出G!你敢信!直接从银牌中段掉到了铁牌区。。。。。。
认真读了多次题,改了无数次代码。。。。。。
这个题看出了配合,题意理解的各种bug
题意:先删去己方的死棋子,再删去对方的死棋子,最后判断,在一步之内,我能否吃掉对方的至少一个子。死棋子的规则同围棋规则
WA:题意读错;在外围加边框之后,有细节点没有注意:以后不要搞边框,老老实实判断在不在界内就好了
很好实现的dfs,得不到铜奖真的是自己的问题!:
#include<bits/stdc++.h>
using namespace std;
const int maxn=20;
bool vis[maxn][maxn];
bool book[maxn][maxn];
char mp[maxn][maxn];
int number,ansflag;
int dirx[]={0,0,1,-1};
int diry[]={1,-1,0,0};
bool Check_In_Map(int x,int y){
	if (x>=1&&x<=9&&y>=1&&y<=9) return true;
	return false;
}
void debug(){
	for(int i=1;i<=9;i++)
		for(int j=1;j<=9;j++)
				printf("%c%c",mp[i][j],j==9?'\n':' ');
	cout<<endl;
}
void dfs_Search1(int x,int y,char ch){
	vis[x][y]=true;
	for(int k=0;k<4;k++){
		int nx=x+dirx[k];
		int ny=y+diry[k];
		if (vis[nx][ny]) continue;
		if (!Check_In_Map(nx,ny)) continue;
		if (mp[nx][ny]=='.') number++;
		else if (mp[nx][ny]==ch) dfs_Search1(nx,ny,ch);
	}
}
void dfs_Search2(int x,int y,char ch){
	vis[x][y]=true;
	for(int k=0;k<4;k++){
		int nx=x+dirx[k];
		int ny=y+diry[k];
		if (vis[nx][ny]) continue;
		if (!Check_In_Map(nx,ny)) continue;
		if (mp[nx][ny]=='.'&&book[nx][ny]==false){
			number++;
			book[nx][ny]=true;
		}
		else if (mp[nx][ny]==ch) dfs_Search2(nx,ny,ch);
	}
}
void dfs_Del(int x,int y,char ch){
	mp[x][y]='.';
	for(int k=0;k<4;k++){
		int nx=x+dirx[k];
		int ny=y+diry[k];
		if (!Check_In_Map(nx,ny)) continue;
		if (mp[nx][ny]==ch) dfs_Del(nx,ny,ch);
	}
}
int main(){
	//freopen("input.txt","r",stdin);
	int i,j,t;
	scanf("%d",&t);
	for(int Case=1;Case<=t;Case++){
		memset(book,false,sizeof(book));
		for(i=1;i<=9;i++) scanf("%s",mp[i]+1);
		ansflag=0;
		memset(book,0,sizeof(book));
		memset(vis,false,sizeof(vis));
		for(i=1;i<=9;i++)
			for(j=1;j<=9;j++)
				if (mp[i][j]=='x'&&!vis[i][j]){
					number=0;
					dfs_Search1(i,j,'x');
					if (number==0) dfs_Del(i,j,'x');
				}
		memset(book,0,sizeof(book));
		memset(vis,false,sizeof(vis));
		for(i=1;i<=9;i++)
			for(j=1;j<=9;j++)
				if (mp[i][j]=='o'&&!vis[i][j]){
					number=0;
					dfs_Search1(i,j,'o');
					if (number==0) dfs_Del(i,j,'o');
				}
		memset(vis,false,sizeof(vis));
		for(i=1;i<=9;i++)
			for(j=1;j<=9;j++)
				if (mp[i][j]=='o'&&!vis[i][j]){
					memset(book,false,sizeof(book));
					number=0;
					dfs_Search2(i,j,'o');
					if (number==1){
						ansflag=1;
						break;
					}
				}
		if (ansflag)
			printf("Case #%d: Can kill in one move!!!\n",Case);
		else
			printf("Case #%d: Can not kill in one move!!!\n",Case);
	}
	return 0;
}    http://acm.hdu.edu.cn/showproblem.php?pid=5547
H题:4*4数独:暴力搜索:注意:找到解马上输出并且返回,因为题中保证了唯一解
#include<bits/stdc++.h>
using namespace std;
char mp[10][10];
bool flag;
bool Check_Row(int x,int y,int number){
	for(int i=1;i<=4;i++)
		if (mp[x][i]-'0'==number) return false;
	return true;
}
bool Check_Line(int x,int y,int number){
	for(int i=1;i<=4;i++)
		if (mp[i][y]-'0'==number) return false;
	return true;
}
bool Check_Square(int x,int y,int number){
	int xx=x%2;
	int yy=y%2;
	int checkx,checky;
	if (xx==1&&yy==1) checkx=x+1,checky=y+1;
	else if (xx==1&&yy==0) checkx=x+1,checky=y-1;
	else if (xx==0&&yy==0) checkx=x-1,checky=y-1;
	else checkx=x-1,checky=y+1;
	if (mp[x][checky]-'0'==number) return false;
	if (mp[checkx][y]-'0'==number) return false;
	if (mp[checkx][checky]-'0'==number) return false;
	return true;
}
void Print(){
	for(int i=1;i<=4;i++) printf("%s\n",mp[i]+1);
}
void dfs(int x,int y){
	if (flag) return;
	if (x==5){
		flag=true;
		Print();
		return;<a target=_blank target="_blank" href="http://acm.hdu.edu.cn/showproblem.php?pid=5551">http://acm.hdu.edu.cn/showproblem.php?pid=5551</a>
	}
	if (y==5) dfs(x+1,1);
	if (mp[x][y]=='*'){
		for(int k=1;k<=4;k++){
			if (Check_Row(x,y,k)&&Check_Line(x,y,k)&&Check_Square(x,y,k)){
				mp[x][y]=k+'0';
				dfs(x,y+1);
				mp[x][y]='*';
				if (flag) return;
			}
		}
	}
	else{
		dfs(x,y+1);
		if (flag) return;
	}
}
int main(){
	int i,t;
	scanf("%d",&t);
	for(int Case=1;Case<=t;Case++){
		for(i=1;i<=4;i++) scanf("%s",mp[i]+1);
		printf("Case #%d:\n",Case);
		flag=false;
		dfs(1,1);
	}
	return 0;
} http://acm.hdu.edu.cn/showproblem.php?pid=5551
L题:水题。输入n,输出()。。。开了题就知道了。。。
赛场上***了,把负号-打成了加号+罚时20分钟。。。你敢信
--------------------------------------------------------------------------------------------------------------------
从我Q的题解中,可以学到更多更好的姿势:
http://blog.csdn.net/quailty/article/details/49275701
赛后补了我会做的一道01背包题,赛场上搞出来成功绝杀夺奖会有会有多么多么多么幸福:
http://acm.hdu.edu.cn/showproblem.php?pid=5543
D题:一个长为l的容器,有n根长为ai的金条,价值为vi,放上去的时候只需要金条的重心在容器上面就好。求最大价值
Q神的题解说得很清楚!
为什么要翻倍:是因为长为1的话重心枚举为0.5不方便做
为什么需要考虑单独的vi是不是最大价值:有可能这个金条特别长,但是特别贵,是可以只放一个放在容器内的
需要最简单的压缩一维的思想即可:不然MLE
代码如下:
int t,n,l,a,v;
ll dp[maxl][3];
ll ans;
int main(){
    int i,j,k;
    scanf("%d",&t);
    for(int Case=1;Case<=t;Case++){
        scanf("%d%d",&n,&l);
        memset(dp,0,sizeof(dp));
        l*=2;
        ans=0;
        for(i=1;i<=n;i++){
            scanf("%d%d",&a,&v);
            a*=2;
            ans=max(ans,(ll)v);
            for(j=l;j>=a/2;j--)
                for(k=0;k<=2;k++)
                    {
                        if(j>=a)
                            dp[j][k]=max(dp[j][k],dp[j-a][k]+(ll)v);
                        if(k>=1)
                            dp[j][k]=max(dp[j][k],dp[j-a/2][k-1]+(ll)v);
                    }
            }
            for(i=0;i<=2;i++)
                ans=max(ans,dp[l][i]);
        printf("Case #%d: %I64d\n",Case,ans);
    }
    return 0;
}                        
 ------------------------------------------------------------------------------------------------------------------------
再来抒发一次我的遗憾心情
------------------------------------------------------------------------------------------------------------------------
面朝北京上海,再次扬帆起航!



京公网安备 11010502036488号