ccpc网络赛Friend-Graph

来源:互联网 发布:python opengl 教程 编辑:程序博客网 时间:2024/06/06 10:59
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!


【题意】

t组样例。

一共有N个人,接下来n-1行给出第i个人和第i+j个人的关系,1是朋友,0则不是朋友。

如果有三个人互相都是朋友或者都不是朋友,输出“Bad Team!”否则输出”Great Team!” 。

【体验】

一开始脑子一抽想到并不熟悉的强连通分量去了。。orz并且还记错了,强连通分量只要相互之间能到达就好,不是两两之间有边。

后来想到n^3的暴力做法又觉得会T,不敢写。。。

最后队友试了试就过了,发现great team的条件很苛刻;

【解法】

当n>=6,输出bad team,否则就great。

为什么大于等于6就不行了呢?

暂时不知道,之后知道了再替换。


以下是我写的蠢蠢的AC代码嘻嘻

#include<cstdio>int map[300][300];int main(){int t;scanf("%d",&t);while(t--){int n;int flag=1;scanf("%d",&n);if(n>=6){flag=0;int x;for(int i=1;i<=n-1;i++){for(int j=1;j<=n-i;j++){scanf("%d",&x);}}}else{for(int i=1;i<=n-1;i++){for(int j=1;j<=n-i;j++){scanf("%d",&map[i][i+j]);map[i+j][i]=map[i][i+j];}}for(int i=1;i<=n-1;i++){for(int j=1;j<=n-i;j++){if(map[i][i+j]){for(int k=1;k<=n;k++){if(k!=i&&k!=i+j&&map[i+j][k]&&map[k][i])flag=0;}}else{for(int k=1;k<=n;k++){if(k!=i&&k!=i+j&&!map[i+j][k]&&!map[k][i])flag=0;}}}}}if(flag)printf("Great Team!\n");else printf("Bad Team!\n");}return 0;}