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 }

 

posted @ 2017-08-20 12:56  sortmin  阅读(100)  评论(0编辑  收藏  举报