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 |
能通过,waIn Reply To:你能通过这些数据吗? Posted by:zhaokkk27 at 2007-09-10 18:05:34 #include<stdio.h> #include<string.h> int n,i,j,k,t; char c; int w[1001]={0},la[101]={0},vi[1001]={0},q=0; int bz[101][550]={0},by[101][550]={0},bal[101]={0},ans,right,left; int main() { scanf("%d %d",&t,&n); for(j=1;j<n+1;j++) { scanf("%d",&la[j]); for(i=0;i<la[j];i++) {scanf("%d",&bz[j][i]); //vi[bz[j][i]]=1; } for(i=0;i<la[j];i++) {scanf("%d",&by[j][i]); //vi[bz[j][i]]=1; } scanf("%c",&c); scanf("%c",&c); if(c=='=') bal[j]=0; else {//q=1; //f/or(i=0;i<la[j];i++) //vi[bz[j][i]]=1,vi[by[j][i]]=1; if(c=='<') bal[j]=-1; else bal[j]=1; } //printf("%d\n",bal[j]); } for(i=1;i<=t;i++) w[i]=1; ans=-1; for(i=1;i<=t;i++) { //if(vi[i]==0&&q==1) // continue; w[i]=0; for(j=1;j<n+1;j++) { right=left=0; for(k=0;k<la[j];k++) { left=w[bz[j][k]]+left; right=w[by[j][k]]+right; } if(left<right&&bal[j]!=-1) break; if(left>right&&bal[j]!=1) break; if(left==right&&bal[j]!=0) break; } if(ans!=-1&&j==n+1) {ans=-1;break;} if(j==n+1) ans=i; if(ans==-1) { w[i]=2; for(j=1;j<n+1;j++) { right=left=0; for(k=0;k<la[j];k++) { left=w[bz[j][k]]+left; right=w[by[j][k]]+right; } if(left<right&&bal[j]!=-1) break; if(left>right&&bal[j]!=1) break; if(left==right&&bal[j]!=0) break; } if(ans!=-1&&j==n+1) {ans=-1;break;} if(j==n+1) ans=i; } w[i]=1; } if(ans!=-1) printf("%d\n",ans); else printf("0\n"); scanf("%d"); return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator