题解参考博客:
http://blog.csdn.net/hjd_love_zzt/article/details/9897281
#include <cstdio> int n,ns,n2,a[65],yes; int main(){ int cas; scanf("%d",&cas); while(cas--){ scanf("%d",&n); for(int i=1;i<=3;i++){ scanf("%d",&ns); for(int j=1;j<=ns;j++){ scanf("%d",&n2); a[n2]=i; } } yes=1; int sor=1,cant=2,des=3,t; for(int i=n;i>=1;i--){ if(a[i]==cant){yes=0;break;} else if(a[i]==des)t=sor,sor=cant,cant=t; else if(a[i]==sor)t=des,des=cant,cant=t; } if(yes)printf("true "); else printf("false "); } return 0; }