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 |
Re:16MS 位运算 代码短!!!In Reply To:16MS 位运算 代码短!!! Posted by:Wsnpyo at 2013-10-30 01:04:41 > #include<iostream> > #include<cstdio> > using namespace std; > int d[1000000],w[1000000],p[1000000]; > int main() > { > int i,j,k=0,g=0,h=1; > for(i=1;i<=4;i++){ > for(j=1;j<=4;j++) > if (getchar()=='b') d[1]=(d[1]<<1)+1; else d[1]=d[1]<<1; > getchar(); > } > p[1]=0; > while(g<h){ > g++; > if(d[g]==0||d[g]==(1<<16)-1) { > printf("%d",w[g]); > k=1; > break; > } > if (h>990000) continue; > for(i=p[g]+1;i<=16;i++){ > h++; > w[h]=w[g]+1; > p[h]=i; > d[h]=d[g]^(1<<(16-i)); > if(i-4>=1) d[h]^=1<<(16-i+4); > if(i+4<=16) d[h]^=1<<(16-i-4); > if(i%4!=0) d[h]^=1<<(16-i-1); > if((i-1)%4!=0) d[h]^=1<<(16-i+1); > } > } > if (!k) printf("Impossible"); > return 0; > } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator