| ||||||||||
| 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 | |||||||||
怎么我以前AC的代码现在打开里面有乱吗啊?奇怪啊Source Code
Problem: 2893 User: ecjtunh
Memory: 2452K Time: 780MS
Language: C++ Result: Accepted
Source Code
//¼ÆËãÄæÐòÊýÖ»ÓÃÒ»¸öÊý×é
#include<stdio.h>
int a[1000003];//char use[1000002];
int main()
{ int i,j,m,n,k,x,i0,t,K,p;
int an,s,c[2];
c[1]=0;c[0]=1;
while(1)
{ scanf("%d%d",&m,&n);
if(m+n==0)break;
k=0;
for(i=1;i<=m;i++)
{ for(j=1;j<=n;j++)
{ scanf("%d",&x);
if(x==0)
{ i0=i;
continue;
}
k++;
a[k]=x;
}
}
// Èç¹ûNÆæÊý £¬Å¼ÅÅÁÐΪ¿ÉÐÐ
// Èç¹ûNżÊý £¬µ±0µ½MÐеľàÀëi0=M-iΪżÊý£¬Å¼ÅÅÁÐΪ¿ÉÐÐ
// µ±0µ½MÐеľàÀëi0=M-iÎªÆæÊý£¬ÆæÅÅÁÐΪ¿ÉÐÐ
i0=m-i0;
if(i0%2==1&&n%2==0)
{ j=a[1];a[1]=a[2];a[2]=j; }
an=0;
K=k;//printf("k=%d\n",k);
for(i=1;i<K;i++)
{ if(a[i])
{ if(a[i]>i)
{ s=a[i];a[i]=0;
t=1;
while(s!=i)
{ p=s; s=a[s]; a[p]=0;t=c[t];
}
if(t==0)an=c[an];
}
}
}
if(an==0)printf("YES\n");
else printf("NO\n");
}
}
/*
3 3
1 0 3
4 2 5
7 8 6
4 3
1 2 5
4 6 9
11 8 10
3 7 0
0 0
Sample Output
YES
NO
Source
POJ Monthly--2006.07.30, newton88518
[Submit] [Go Back] [Status] [Discuss]
Home Page Go
*/
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator