• POJ 2443 Set Operation


    叉姐初级魔法训练赛A题

    1000个集合,每个集合有10000个数每个数不大于10000...

    200000个询问是否存在i,j属于同一个set

    集合很少...我们就暴力一下就行了...

    暴力开10000*1000的bool数组存 数字i在j集合中是否出现...

    每次O(n)...

    /********************* Template ************************/
    #include <set>
    #include <map>
    #include <list>
    #include <cmath>
    #include <ctime>
    #include <deque>
    #include <queue>
    #include <stack>
    #include <bitset>
    #include <cstdio>
    #include <string>
    #include <vector>
    #include <cassert>
    #include <cstdlib>
    #include <cstring>
    #include <sstream>
    #include <fstream>
    #include <numeric>
    #include <iomanip>
    #include <iostream>
    #include <algorithm>
    #include <functional>
    using namespace std;
    #define EPS         1e-8
    #define DINF        1e15
    #define MAXN        10050
    #define LINF        1LL << 60
    #define MOD         1000000007
    #define INF         0x7fffffff
    #define PI          3.14159265358979323846
    #define lson            l,m,rt<<1
    #define rson            m+1,r,rt<<1|1
    #define BUG             cout<<" BUG! "<<endl;
    #define LINE            cout<<" ------------------ "<<endl;
    #define FIN             freopen("in.txt","r",stdin);
    #define FOUT            freopen("out.txt","w",stdout);
    #define mem(a,b)        memset(a,b,sizeof(a))
    #define FOR(i,a,b)      for(int i = a ; i < b ; i++)
    #define read(a)         scanf("%d",&a)
    #define read2(a,b)      scanf("%d%d",&a,&b)
    #define read3(a,b,c)    scanf("%d%d%d",&a,&b,&c)
    #define write(a)        printf("%d
    ",a)
    #define write2(a,b)     printf("%d %d
    ",a,b)
    #define write3(a,b,c)   printf("%d %d %d
    ",a,b,c)
    #pragma comment         (linker,"/STACK:102400000,102400000")
    template<class T> inline T L(T a)       {return (a << 1);}
    template<class T> inline T R(T a)       {return (a << 1 | 1);}
    template<class T> inline T lowbit(T a)  {return (a & -a);}
    template<class T> inline T Mid(T a,T b) {return ((a + b) >> 1);}
    template<class T> inline T gcd(T a,T b) {return b ? gcd(b,a%b) : a;}
    template<class T> inline T lcm(T a,T b) {return a / gcd(a,b) * b;}
    template<class T> inline T Min(T a,T b) {return a < b ? a : b;}
    template<class T> inline T Max(T a,T b) {return a > b ? a : b;}
    template<class T> inline T Min(T a,T b,T c)     {return min(min(a,b),c);}
    template<class T> inline T Max(T a,T b,T c)     {return max(max(a,b),c);}
    template<class T> inline T Min(T a,T b,T c,T d) {return min(min(a,b),min(c,d));}
    template<class T> inline T Max(T a,T b,T c,T d) {return max(max(a,b),max(c,d));}
    template<class T> inline T exGCD(T a, T b, T &x, T &y){
        if(!b) return x = 1,y = 0,a;
        T res = exGCD(b,a%b,x,y),tmp = x;
        x = y,y = tmp - (a / b) * y;
        return res;
    }
    typedef long long LL;    typedef unsigned long long ULL;
    //typedef __int64 LL;      typedef unsigned __int64 ULL;
    /*********************   By  F   *********************/
    bool pos[MAXN][1005];
    int n,m,p;
    bool query(int a,int b)
        for(int i = 0 ; i < 1005 ; i++){
            if(pos[a][i] && pos[b][i]) return true;
        return false;
    }
    int main(){
        //FIN;
        //FOUT;
        while(~read(n)){
            int i,j,x;
            mem(pos,false);
            for(i = 0 ; i < n ; i++){
                read(p);
                while(p--){
                    read(x);
                    pos[x][i] = 1;
                }
            }
            read(m);
            while(m--){
                read2(i,j);
                printf("%s
    ",query(i,j)?"Yes":"No");
            }
        }
        return 0;
    }
  • 相关阅读:
    XmlDocument.selectNodes() and selectSingleNode()的xpath的学习资料
    config相关操作(转)
    网站存储session的方案
    VS2015 C#6.0 中的那些新特性(转自http://www.cnblogs.com/henryzhu/p/new-feature-in-csharp-6.html)
    ERROR L105: PUBLIC REFERS TO IGNORED SEGMENT 的解决办法
    关于C51内的code,idata,xdata
    KeilC51使用详解 (三)
    KeilC51使用详解 (二)
    KeilC51使用详解 (一)
    变量初始化
  • 原文地址:https://www.cnblogs.com/Felix-F/p/3341529.html
Copyright © 2020-2023  润新知