zoukankan      html  css  js  c++  java
  • Winner

    南昌邀请赛 暴力模拟
    #include<bits/stdc++.h>
    using namespace std;
    struct Nod
    {
        int i;
        int a,b,c;
    } A[100004];
    bool f[100004];
    int B[100004][3];
    bool cmp1(Nod a,Nod b)
    {
        return a.a<b.a;
    }
    bool cmp2(Nod a,Nod b)
    {
        return a.b<b.b;
    }
    bool cmp3(Nod a,Nod b)
    {
        return a.c<b.c;
    }
    int main()
    {
        int N,Q;
        scanf("%d%d",&N,&Q);
        int t;
        for(int i=0; i<=N-1; i++)
        {
            scanf("%d",&t);
            A[i].i=i+1;
            A[i].a=t;
        }
        for(int i=0; i<=N-1; i++)
        {
            scanf("%d",&t);
            A[i].b=t;
        }
        for(int i=0; i<=N-1; i++)
        {
            scanf("%d",&t);
            A[i].c=t;
        }
        bool g=0;
        sort(A,A+N,cmp1);
        f[A[N-1].i]=1;
        for(int i=0; i<N; i++)
        {
            B[i][0]=A[i].i;
        }
        sort(A,A+N,cmp2);
        f[A[N-1].i]=1;
        g=0;
        for(int i=0; i<N; i++)
        {
            B[i][1]=A[i].i;
            if(f[A[i].i])
            {
                g=1;
            }
            if(g&&f[A[i].i]==0)
            {
                f[A[i].i]=1;
            }
        }
        sort(A,A+N,cmp3);
        f[A[N-1].i]=1;
        g=0;
        for(int i=0; i<N; i++)
        {
            B[i][2]=A[i].i;
            if(f[A[i].i])
            {
                g=1;
            }
            if(g&&f[A[i].i]==0)
            {
                f[A[i].i]=1;
            }
        }
        while(true)
        {
            bool ch=0;
            g=0;
            for(int i=0; i<N; i++)
            {
                if(f[B[i][0]])
                {
                    g=1;
                }
                if(g&&f[B[i][0]]==0)
                {
                    ch=1;
                    f[B[i][0]]=1;
                }
            }
            g=0;
            for(int i=0; i<N; i++)
            {
                if(f[B[i][1]])
                {
                    g=1;
                }
                if(g&&f[B[i][1]]==0)
                {
                    ch=1;
                    f[B[i][1]]=1;
                }
            }
            g=0;
            for(int i=0; i<N; i++)
            {
                if(f[B[i][2]])
                {
                    g=1;
                }
                if(g&&f[B[i][2]]==0)
                {
                    ch=1;
                    f[B[i][2]]=1;
                }
            }
            if(!ch)break;
        }
        while(Q--)
        {
            scanf("%d",&t);
            if(f[t])
            {
                puts("YES");
            }
            else puts("NO");
        }
    }
  • 相关阅读:
    数据库使用动态监听导致EM起不来的解决方法
    OCP-1Z0-053-V12.02-115题
    OCP-1Z0-053-V12.02-150题
    OCP-1Z0-053-V12.02-136题
    OCP-1Z0-053-V12.02-154题
    OCP-1Z0-053-V12.02-149题
    OCP-1Z0-053-V12.02-146题
    OCP-1Z0-053-V12.02-160题
    OCP-1Z0-053-V12.02-157题
    OCP-1Z0-053-V12.02-164题
  • 原文地址:https://www.cnblogs.com/liulex/p/11274663.html
Copyright © 2011-2022 走看看