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 |
这题思路不是这样吗?我感觉没错啊..WA了,哪位站友能告诉我错在哪吗? #include <stdio.h> #include <string.h> int a[1000000]; int b[1000000]; int c[1000000]; char d[1000000][4]; bool t[1001][1001][4];/*0表 同时0;1表同时1;2表0,1;3表1,0;*/ int main() { /*freopen("in.txt","r",stdin); freopen("out.txt","w",stdout);*/ int n,m,i,j,k,tag; while (scanf("%d%d",&n,&m)!=EOF) { for(i=0;i<m;i++) { scanf("%d %d %d",&a[i],&b[i],&c[i]); gets(d[i]); } if(m==0) { printf("YES\n"); continue; } tag=0; memset(t,0,sizeof(t)); for(i=0;i<m;i++) { if(d[i][0]=='A') { if(c[i]==1) { t[a[i]][b[i]][1]=t[b[i]][a[i]][1]=1; } else { t[a[i]][b[i]][0]=t[b[i]][a[i]][0]=t[a[i]][b[i]][2]=t[a[i]][b[i]][3] =t[b[i]][a[i]][2]=t[b[i]][a[i]][3]=1; } if((t[a[i]][b[i]][0]||t[a[i]][b[i]][2])&&(t[a[i]][b[i]][1]||t[a[i]][b[i]][3])) { tag=1; break; } if((t[b[i]][a[i]][0]||t[b[i]][a[i]][2])&&(t[b[i]][a[i]][1]||t[b[i]][a[i]][3])) { tag=1; break; } } else if(d[i][0]=='O') { if(c[i]==1) { t[a[i]][b[i]][1]=t[a[i]][b[i]][2]=t[a[i]][b[i]][3]=1; t[b[i]][a[i]][1]=t[b[i]][a[i]][2]=t[b[i]][a[i]][3]=1; } else { t[a[i]][b[i]][0]=t[b[i]][a[i]][0]=1; } if((t[a[i]][b[i]][0]||t[a[i]][b[i]][2])&&(t[a[i]][b[i]][1]||t[a[i]][b[i]][3])) { tag=1; break; } if((t[b[i]][a[i]][0]||t[b[i]][a[i]][2])&&(t[b[i]][a[i]][1]||t[b[i]][a[i]][3])) { tag=1; break; } } else if(d[i][0]=='X') { if(c[i]==1) { t[a[i]][b[i]][2]=t[a[i]][b[i]][3]=1; t[b[i]][a[i]][2]=t[b[i]][a[i]][3]=1; } else { t[a[i]][b[i]][1]=t[b[i]][a[i]][1]=t[a[i]][b[i]][0]=t[b[i]][a[i]][0]=1; } if((t[a[i]][b[i]][0]||t[a[i]][b[i]][2])&&(t[a[i]][b[i]][1]||t[a[i]][b[i]][3])) { tag=1; break; } if((t[b[i]][a[i]][0]||t[b[i]][a[i]][2])&&(t[b[i]][a[i]][1]||t[b[i]][a[i]][3])) { tag=1; break; } } } if(tag) printf("NO\n"); else printf("YES\n"); } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator