zoukankan      html  css  js  c++  java
  • L2-023. 图着色问题

    题也不算难,刚开始没读懂题意的这个无向图,后来在纸上画一下就明白了,如果大家也是不明白题意就自己画一画就明白了。

    题不算难,还是需要用set,解决起来比较方便,代码如下:(一个两分的样例过不去,大家借鉴一下然后自己在写写吧)

    #include<stdio.h>
    #include<string.h>
    #include<math.h>
    #include<time.h>
    #include<ctype.h>
    #include<map>
    #include<set>
    #include<algorithm>
    #include<stdlib.h>
    #include<queue>
    #include<stack>
    using namespace std;
    struct DD
    {
        int u,v;
    
    }A[10000005];
    int num[1001];
    set<int >s;
    int main()
    {
        int a,b,c,i,j;
        scanf("%d%d%d",&a,&b,&c);
        for(i=0;i<b;i++)
            scanf("%d%d",&A[i].u,&A[i].v);
            int m;
            scanf("%d",&m);
            while(m--)
            {      s.clear();
                for(i=1;i<=a;i++)
                {
                    scanf("%d",&num[i]);
                    s.insert(num[i]);
                }
                if(s.size()>c)
                {
                    printf("No
    ");
                    continue;
                }
                int fla=0;
                for(i=0;i<b;i++)
                {
                    if(num[A[i].u]==num[A[i].v])
                    {
                        fla=1;
                        break;
                    }
                }
                if(fla)
                printf("No
    ");
                else
                    printf("Yes
    ");
    
            }
    }
  • 相关阅读:
    php之异常处理
    php7之严格模式RFC
    获取真实ip三个方法
    php网站速度性能优化(转)
    PHPweb应用攻击总结(转)
    PHP安全之Web攻击(转)
    php获取真实ip地址(转)
    单表查询
    表与表之间的关系
    表的操作
  • 原文地址:https://www.cnblogs.com/nr1999/p/8625972.html
Copyright © 2011-2022 走看看