# 朋友圈（拉姆齐定理）- HDU 6152

6个人中必有3个人相互认识或者相互不认识。

Problem Description

It is well known that small groups are not conducive of the development of a team. Therefore, there shouldn’t be any small groups in a good team.

In a team with n members,if there are three or more members are not friends with each other or there are three or more members who are friends with each other. The team meeting the above conditions can be called a bad team.Otherwise,the team is a good team.

A company is going to make an assessment of each team in this company. We have known the team with n members and all the friend relationship among these n individuals. Please judge whether it is a good team.

Input

The first line of the input gives the number of test cases T; T test cases follow.（T<=15） The first line od each case should contain one integers n, representing the number of people of the team.(n≤3000)

Then there are n-1 rows. The ith row should contain n-i numbers, in which number aij represents the relationship between member i and member j+i. 0 means these two individuals are not friends. 1 means these two individuals are friends.

Output

Sample Input

```1
4
1 1
0 0
0 1```

Sample Output

`Great Team!`

```#include <bits/stdc++.h>
using namespace std;

bool G[6][6];

int main()
{
int T;
scanf("%d", &T);
//用例次数
while ( T-- )
{
int n;
scanf("%d", &n);

//输入n-1行
for ( int i = 1; i <= n; i++ )
{
for ( int j = i + 1; j <= n; j++ )
{
int e;
scanf("%d", &e);
//设置关系
if ( n <= 6 )
G[j][i] = G[i][j] = e;
}
}

//如果只有1、2个人，则肯定是好团队（要么认识、要么不认识）
if (n < 3)
{
printf("Great Team!\n");
continue;
}

//如果大于6个人，则肯定是不好的团队，根据拉姆齐定理： 6 个人中至少存在3人相互认识或者相互不认识。
if (n >= 6)
{
continue;
}

//暴力搜索（量级非常小）
bool flag = false;
for ( int a = 1; a <= n; a++ )
for ( int b = a + 1; b <= n; b++ )
for ( int c = b + 1; c <= n; c++ )
if ( (G[a][b] && G[a][c] && G[b][c]) ||
(!G[a][b] && !G[a][c] && !G[b][c]) )
flag = true;

if ( flag )  printf("Bad Team!\n");
else printf("Great Team!\n");
}
return 0;
}```

235 篇文章37 人订阅

0 条评论

## 相关文章

### 200行代码，一行行教你自制微信机器人

1） 用一个windows客户端工具运营公众号，真的很局限。虽然工具的功能很强大，能自动添加好友，自动拉好友入群，关键字回复等等，但是有一个绕不开的点，它是一款...

62120

11610

### TFS2018环境搭建一硬件要求

TFS可以安装在Windows Server和Windows PC操作系统中,但是TFS2018和2018只支持64位操作系统中,早期的版本没有操作系统的位数限...

41030

21530

25230

11840

21440

21330

15830

13920