Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:16MS 位运算 代码短!!!

Posted by 03194766958 at 2014-07-19 17:33:34 on Problem 1753
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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator