zoukankan      html  css  js  c++  java
  • 2017 CCPC 1003. Friend-Graph

    题意:判定一个无向图是否有三个点的团或者三个点的独立集。

    题解:Ramsey theorem,n >= 6 直接输出 Bad 否则暴力。

    当时AC做法是直接找度  度大于2即Bad

    AC代码:

     1 #include <bits/stdc++.h>
     2 using namespace std;
     3 int n;
     4 int t;
     5 int cnt[3002], cnt2[3002];
     6 int xx()
     7 {
     8     int x;
     9      for (int i = 1; i <= n; i++)
    10         {
    11             for (int j = i+1; j <= n; j++)
    12             {
    13                 scanf("%d", &x);
    14                 if (x)
    15                 {
    16                     cnt[i]++;
    17                     cnt[j]++;
    18                 }
    19                 else
    20                 {
    21                     cnt2[i]++;
    22                     cnt2[j]++;
    23                 }
    24             }
    25         }
    26 }
    27 int main()
    28 {
    29 
    30     scanf("%d",&t);
    31     while (t--)
    32     {
    33         scanf("%d",&n);
    34         int x;
    35         bool k=false;
    36         memset(cnt, 0, sizeof(cnt));
    37         memset(cnt2, 0, sizeof(cnt2));
    38         xx();
    39         for(int i=1;i<=n;i++)
    40         {
    41             if(cnt[i]>2||cnt2[i]>2)
    42             {
    43                 k=true;
    44                 break;
    45             }
    46         }
    47         if (!k)
    48             puts("Great Team!");
    49         else
    50             puts("Bad Team!");
    51 
    52     }
    53     return 0;
    54 }
  • 相关阅读:
    存储器多级结构
    649. Dota2 参议院
    pycharm安装第三方库失败
    python -m pip install --upgrade pip升级失败
    P1149 火柴棒等式
    HTTP详解
    ref与out
    EF查询数据库框架的搭建
    EF查询数据库框架的搭建
    css清除浮动
  • 原文地址:https://www.cnblogs.com/sortmin/p/7399642.html
Copyright © 2011-2022 走看看