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.
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 i
th row should contain n-i numbers, in which number
a
ij![]()
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.
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 i
Output
Please output ”Great Team!” if this team is a good team, otherwise please output “Bad Team!”.
Sample Input
1#include<iostream> #include<cstring> #include<cstdio> #include<algorithm> using namespace std; int a[10][10]; int main() { int n,m,i,j,t,k; scanf("%d",&t); while(t--) { memset(a,0,sizeof(a)); scanf("%d",&n); if(n>=6) { for(i=0;i<(n-1)*n/2;i++) scanf("%d",&m); printf("Bad Team!\n"); continue; } for(i=1; i<=n-1; i++) { for(j=i+1; j<=n; j++) { scanf("%d",&m); a[i][j]=m; a[j][i]=m; } } if(n<3) { printf("Great Team!\n"); continue; } int f=0; int sum=0; for(i=1; i<=n; i++) { for(j=i+1; j<=n; j++) { for(k=j+1; k<=n; k++) { if(a[i][j]==a[i][k]&&a[i][j]==a[j][k]) { printf("Bad Team!\n"); f=1; break; } } if(f==1) break; } if(f==1) break; } if(f==0) printf("Great Team!\n"); } return 0; }
41 1 00 01
Sample Output
Great Team!
题意:判定一个无向图是否有三个点的团或者三个点的独立集。
题解:Ramsey theorem,n >= 6 直接输出 Bad 否则暴力。