Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
求大牛给点测试数据,狂WA疯了给点数据吧,题目的测试数据都对,为什么WA?#include<stdio.h> #include<iostream> int puzzle[7][8],answer[7][8],puzzle0[7][8]; int one[7]; void trans2(int x) //转换为二进制的函数 ,必须小于64 { int m=x,n,l=6; while(m>0){ if(l<1) break; n=m%2; m/=2; one[l]=n; l--; } } void init(int k) { int m,n; for(m=1;m<=5;++m){ for(n=1;n<=6;++n){ if(1==k) puzzle[m][n]=0; else if(2==k) answer[m][n]=0; else{ puzzle[m][n]=0; answer[m][n]=0; } } } } void printAnswer() { for(int o=1;o<6;++o) { for(int p=1;p<=6;++p) { printf("%d",answer[o][p]); if(p!=6) printf(" "); } printf("\n"); } } void over(int &y) { if(y==1) y=0; else y=1; } void press(int a,int b) { answer[a][b]=1; over(puzzle[a][b]); over(puzzle[a+1][b]); over(puzzle[a-1][b]); over(puzzle[a][b+1]); over(puzzle[a][b-1]); } void pressOne(int z)//枚举第一行,共 64种 { trans2(z); for(int c=1;c<=6;++c){ if(one[c]==1) press(1,c); } } bool isOK() { for(int e=1;e<=4;++e){ for(int f=1;f<=6;++f){ if(puzzle[e][f]==1) press(e+1,f); } } for(int k=1;k<=6;++k){ if(puzzle[5][k]!=0) return false; } return true; } void getPuzzle0() { for(int o=1;o<6;++o){ for(int p=1;p<=6;++p) puzzle[o][p]=puzzle0[o][p]; } } int main() { freopen("input_poj1222.txt", "r", stdin); freopen("output.txt", "w", stdout); int N; int i,j,g; scanf("%d",&N); for(int g=0;g<N;++g) { for(i=0;i<5;++i) scanf("%d%d%d%d%d%d",&puzzle0[i+1][1],&puzzle0[i+1][2], &puzzle0[i+1][3],&puzzle0[i+1][4], &puzzle0[i+1][5],&puzzle0[i+1][6]); for(i=0;i<64;++i) { init(0); getPuzzle0(); pressOne(i); if(isOK()) break; } printf("PUZZLE #%d\n",g+1); printAnswer(); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator