您的位置:首页 > 理论基础 > 计算机网络

[ccpc网络赛]Friend-Graph

2017-08-27 16:40 246 查看


Friend-Graph

Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)

Total Submission(s): 6514    Accepted Submission(s): 1610


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

Please output ”Great Team!” if this team is a good team, otherwise please output “Bad Team!”.

 

Sample Input

1
4
1 1 0
0 0
1

 

Sample Output

Great Team!

可直接暴力枚举,也可用拉姆齐(Ramsey)定理

在组合数学上,拉姆齐(Ramsey)定理是要解决以下的问题:要找这样一个最小的数n,使得n个人中必定有k个人相识或l个人互不相识。 
拉姆齐定理的通俗表述: 
6 个人中至少存在3人相互认识或者相互不认识。 
该定理等价于证明这6个顶点的完全图的边,用红、蓝二色任意着色,必然至少存在一个红色边三角形,或蓝色边三角形。 
注:这个定理以弗兰克·普伦普顿·拉姆齐命名,1930年他在论文On a Problem in Formal Logic[2](《形式逻辑上的一个问题》)证明了R(3,3)=6。

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <climits>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <list>
#define rep(i,m,n) for(int i=m;i<=n;i++)
#define rsp(it,s) for(set<int>::iterator it=s.begin();it!=s.end();it++)
const int inf_int = 2e9;
const long long inf_ll = 2e18;
#define inf_add 0x3f3f3f3f
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pi acos(-1.0)
#define pii pair<int,int>
#define Lson L, mid, rt<<1
#define Rson mid+1, R, rt<<1|1
const int maxn=5e2+10;
using namespace std;
typedef vector<int> vi;
typedef long long ll;
typedef unsigned long long ull;
inline int read(){int ra,fh;char rx;rx=getchar(),ra=0,fh=1;
while((rx<'0'||rx>'9')&&rx!='-')rx=getchar();if(rx=='-')
fh=-1,rx=getchar();while(rx>='0'&&rx<='9')ra*=10,ra+=rx-48,
rx=getchar();return ra*fh;}

//#pragma comment(linker, "/STACK:102400000,102400000")
ll gcd(ll p,ll q){return q==0?p:gcd(q,p%q);}
ll qpow(ll p,ll q){ll f=1;while(q){if(q&1)f=f*p;p=p*p;q>>=1;}return f;}
int dir[4][2]={{-1,0},{1,0},{0,-1},{0,1}};

const int N = 3005;

int T,n;
int fl;
int t;
int main()
{
ios_base::sync_with_stdio(false);
// freopen("data.txt","r",stdin);
cin >>T;
for(int k=0;k<T;k++)
{
fl = 0;
cin >> n;
if(n>6)
{
cout <<"Bad Team!"<<endl;
continue;
}
int a,b;
for(int i=1;i<=n-1;i++)
{
a=b=0;
for(int j=i+1;j<=n;j++)
{
cin >> t;
if(t)
{
a++;
}
else
{
b++;
}
}
if(a>=3||b>=3) fl = 1;
}

if(fl)
{
cout <<"Bad Team!"<<endl;
}
else
{
cout <<"Great Team!"<<endl;
}
}

return 0;
}

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: