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!
直接判断三个连在一起的或三个不连在一起的。就是判断能形成三角形的和三个之间没有一条线相连的
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; }
相关文章推荐
- hdu6152 Friend-Graph (2017 ccpc 网络赛 (暴力 + 一个神奇的定理)
- 2017 ccpc 网络赛 Friend-Graph
- [ccpc网络赛]Friend-Graph
- hdu 6152 : Friend-Graph (2017 CCPC网络赛 1003)
- 2017乌鲁木齐赛区网络赛 I Colored Graph(完全图边定向构造)
- 2017 ACM-ICPC南宁网络赛: J. Minimum Distance in a Star Graph(BFS)
- 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛 Minimum Distance in a Star Graph
- HDU 4725-J - The Shortest Path in Nya Graph-增点建图-层次网络-最短路
- HDU 6152-Friend-Graph(ccpc)
- 2017 CCPC网络赛 hdu6153 KMP
- 2017中国大学生程序设计竞赛 - 网络选拔赛 HDU 6152 Friend-Graph(暴力搜索)
- 2017 ccpc网络赛 1001 Vertex Cover(二分图 构造)HDU6150
- 使用C++ Boost Graph Library 进行社交网络分析入门篇
- 【2016-大连赛区网络赛-I】补图最短路(Sparse Graph,hdu 5876)
- HDU 5876 大连网络赛 Sparse Graph
- 2017 CCPC 网络赛 1007
- HDU 6153 A Secret CCPC网络赛,KMP拓展应用
- Introduction to graph theory 图论/脑网络基础
- HDU-5832-A water problem【2016CCPC网络赛】
- HDU 5876 大连网络赛 Sparse Graph