| ||||||||||
| 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:飘逸的位运算In Reply To:飘逸的位运算 Posted by:fanhqme at 2009-04-25 15:13:57 > scanf("%d",&N);
> S=0;
> for (int i=0;i<N;i++){
> scanf("%d",&x);
> S^=(x<<i);
> }
> for (int i=0;i<N;i++){
> scanf("%d",&x);
> S^=(x<<i);
> }
> for (int i=0;i<N;i++)A[i]=((S&(1<<i))&&1)+(1<<(i+1));
> while (scanf("%d %d",&x,&y),x+y)A[y-1]|=(1<<x);
> res=N;
> for (int i=0;i<N;i++){
> k=i;
> for (int j=i+1;j<N;j++)if (A[j]>A[k])k=j;
> x=A[i];A[i]=A[k];A[k]=x;
> if (A[i]<2){
> res=i;
> break;
> }
> for (int j=i+1;j<N;j++)if (HighestBit(A[i])==HighestBit(A[j]))A[j]^=A[i];
> }
> if (res<N && A[res])puts("Oh,it's impossible~!!");
> else printf("%d\n",1<<(N-res));
嗯,对
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator