这个题目 是有一定价值的 以后学会这么搞了;哈哈
1 #include2 #include 3 #include 4 #include 5 using namespace std; 6 7 int arr[10001][34]; 8 9 int main( )10 {11 int i,j,N,M,C,u,v,val;12 while( scanf("%d",&N) != EOF )13 {14 memset( arr,0,sizeof(arr) );15 for( j = 0; j < N; j++ )16 {17 scanf("%d",&C);18 for( i = 1; i <= C; i++ )19 {20 scanf("%d",&val);21 int bit = (1<<(j%32));22 if( (arr[val][j/32] & bit) == 0 )23 arr[val][j/32] += bit;24 }25 }26 scanf("%d",&M);27 for( i = 1; i <= M; i++ )28 {29 scanf("%d%d",&u,&v);30 for( j = 0; j <= 32; j++ )31 if( arr[u][j]&arr[v][j] )32 {33 printf("Yes\n");34 break;35 }36 if( j > 32 )printf("No\n");37 }38 }39 return 0;40 }