zoukankan      html  css  js  c++  java
  • poj 2443 Set Operation 位运算

    这个题目  是有一定价值的   以后学会这么搞了;哈哈    

     1 #include<iostream>
     2 #include<stdio.h>
     3 #include<cstring>
     4 #include<algorithm>
     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 }
  • 相关阅读:
    HDU 4334
    HDU 1280
    HDU 1060
    HDU 4033
    大三角形分成4个面积相等的小三角形
    HDU 1087
    HDU 4313
    Sleep(0)及其使用场景
    Decorator(装饰、油漆工)对象结构型模式
    Debug Assertion Failed!
  • 原文地址:https://www.cnblogs.com/wulangzhou/p/2983567.html
Copyright © 2011-2022 走看看