http://acm.hdu.edu.cn/showproblem.php?pid=1259
水题
View Code
#include <stdio.h> #include <string.h> int main() { int n,m,x,y,i,a[10]; scanf("%d",&n); while(n--) { memset(a,0,sizeof(a)); a[2]=1; scanf("%d",&m); while(m--) { scanf("%d%d",&x,&y); if(a[x])a[x]=0,a[y]=1; else if(a[y])a[y]=0,a[x]=1; else continue; } for(i=1;i<=7;i++) if(a[i]) break; printf("%d\n",i); } return 0; }