当前位置: 代码迷 >> 综合 >> POJ2443 Set Operation(Bitset)
  详细解决方案

POJ2443 Set Operation(Bitset)

热度:0   发布时间:2024-01-18 18:33:08.0

 

http://poj.org/problem?id=2443
 

 学习一下Bitset

 

AC代码:

#include <bitset>
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
const int maxn = 10000 + 5;
bitset<maxn> a[maxn];
int N, Q;
int x, y;
int m, p;
int main() {//清零//for(int i = 0; i < maxn; i++) a[i].reset();scanf("%d",&N);for(int i = 1; i <= N; i++) {scanf("%d",&m);for(int j = 1; j <= m; j++) {scanf("%d",&p);a[p].set(i);}}scanf("%d",&Q);while(Q--) {scanf("%d%d",&x,&y);int flag = 0;if((a[x] & a[y]).any()) flag = 1;if(flag) printf("Yes\n");else printf("No\n");}return 0;
}

 

  相关解决方案