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

hdu5152.Friend-Graph(CCPC网络赛)

2017-08-20 11:03 246 查看
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!

直接判断三个连在一起的或三个不连在一起的。就是判断能形成三角形的和三个之间没有一条线相连的

**#include <cstdio>
#include <iostream>
using namespace std;

const int maxn=3000+10;
int n;
int g[maxn][maxn];

int main(void){
int t;
cin>>t;
while(t--){
cin>>n;
for(int i=1;i<n;i++)
for(int j=1;j+i<=n;j++){
scanf("%d",&g[i][j+i]);
}
bool great=true;
for(int a=1;a<n-1;a++){
bool flag=false;
for(int b=a+1;b<n;b++){
if(g[a][b]){
for(int c=b+1;c<=n;c++){
if(g[b][c]&&g[a][c]){
flag=true;
break;
}
}
}
else{
for(int c=b+1;c<=n;c++){
if(!g[b][c]&&!g[a][c]){
flag=true;
break;
}
}
}
if(flag) break;
}
if(flag){
great=false;
break;
}
}
cout<<(great?"Great Team!":"Bad Team!")<<endl;
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: