| ||||||||||
| 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:chenpeng_125 at 2013-10-14 12:33:57 > #include<iostream>
> #include<algorithm>
>
> using namespace std;
>
> #define N 30
>
> int b[N];
> int a[N][N];
>
> int n;
>
> int count()
> {
> int t=0;
> for (int i=1;i<=n-1;i++)
> {
> int row=i;
> for (int k=i+1;k<=n;k++)
> if (a[i][i]<a[k][i])
> row=k;
> if (row!=i)
> {
> for (int k=i;k<=n;k++)
> swap(a[i][k],a[row][k]);
> swap(b[i],b[row]);
> }
>
> if (a[i][i]==0) continue;
> t=i;
>
> for (int k=i+1;k<=n;k++)
> {
> if (a[k][i]!=0)
> {
> for (int j=i;j<=n;j++)
> a[k][j]^=a[i][j];
> b[k]^=b[i];
> }
> }
> }
>
> if (t==n-1)
> if (a[n][n]==1)
> t++;
>
> for (int k=t+1;k<=n;k++)
> if (b[k]!=0) return 0;
>
> return (1<<(n-t));
> }
>
>
> int main()
> {
> int k;
> cin>>k;
> while (k--)
> {
> memset(a,0,sizeof(a));
> cin>>n;
> for (int i=1;i<=n;i++)
> cin>>b[i];
> for (int i=1;i<=n;i++)
> {
> int end;
> cin>>end;
> b[i]^=end;
>
> a[i][i]=1;
> }
> int start,end;
> while ((cin>>start>>end)&&(start||end))
> a[end][start]=1;
>
> int t=count();
> if (t==0)
> cout<<"Oh,it's impossible~!!"<<endl;
> else
> cout<<t<<endl;
> }
> return 0;
> }
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator