| ||||||||||
| 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:Re:why WA Posted by:lookus at 2004-09-12 22:04:30 > #include <stdio.h>
> int g[1001][1001],n;
> int p[1001][1010],q;
> int v[1001];
> int next(int k)
> {
> int i;
> for(i=1;i<=n;i++)
> if(g[k][i] && v[i]==0)
> {
> p[q][p[q][0]] = i;
> p[q][0]++;
> // printf("%d ",i);
> v[i] = 1;
> return i;
> }
> return 0;
> }
> int back(int k)
> {
> int i;
> for(i=1;i<=n;i++)
> if(g[i][k] && v[i]==0)
> {
> p[q][p[q][1009]] = i;
> p[q][1009]--;
> // printf("%d ",i);
> v[i] = 1;
> return i;
> }
> return 0;
> }
> int apath()
> {
> int i,b;
> for(i=1;i<=n;i++)
> if(v[i]==0)
> break;
> if(i>n)
> return 0;
> p[q][0] = 2;
> p[q][1] = i;
> p[q][1009] = 1008;
> // printf("%d ",i);
> v[i] = 1;
> b = i;
> while(i)
> i = next(i);
> i = b;
> while(i)
> i = back(i);
> return 1;
> }
> void main()
> {
> int i,j;
> while(scanf("%d",&n)!=EOF)
> {
> for(i=1;i<=n;i++)
> {
> v[i] = 0;
> for(j=1;j<=n;j++)
> scanf("%d",&g[i][j]);
> }
> q = 0;
> while(apath())
> q++;
> printf("%d\n",q);
> for(i=0;i<q;i++)
> {
> printf("%d\n",1007+p[i][0] -p[i][1009]);
> for(j=p[i][1009]+1;j<=1008;j++)
> printf("%d ",p[i][j]);
> for(j=1;j<p[i][0];j++)
> printf("%d ",p[i][j]);
> printf("\n");
> }
> } }
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator