【组合数学--拉姆齐定理】hdu 6152 Friend-Graph
来源:互联网 发布:淘宝订单险 编辑:程序博客网 时间:2024/05/22 02:13
Friend-Graph
Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1204 Accepted Submission(s): 618
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. Thei th 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.
The first line od each case should contain one integers n, representing the number of people of the team.(
Then there are n-1 rows. The
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
4
1 1 0
0 0
1
Sample Output
Great Team!
题意:如果有三个或以上的人彼此认识或者彼此不认识输出Bad Team!;
思路:拉姆齐定理:6个人中至少有3个人互相认识或故乡不认识;
代码:
#include<iostream>#include<cstdio>#include<cstring>#include<algorithm>using namespace std;#define por(i,j,k) for(int i=j;i<=k;i++)#define nor(i,j,k) for(int i=j;i>=k;i--)#define clean(a,b) memset(a,0,sizeof(a))bool w[10][10];int n;bool solve(){ por(i,1,n) por(j,i+1,n) por(k,j+1,n) { if(w[i][j]==w[i][k]&&w[i][k]==w[j][k]&&w[j][k]==w[i][j]) return false; } return true;}int main(){ int t; scanf("%d",&t); while(t--) { scanf("%d",&n); if(n<6) { por(i,1,n-1) por(j,i+1,n) { int x; scanf("%d",&x); if(x==1) w[i][j]=w[j][i]=true; else w[i][j]=w[j][i]=false; } if(solve()) printf("Great Team!\n"); else printf("Bad Team!\n"); } else { int x; por(i,1,n-1) por(j,i+1,n) scanf("%d",&x); printf("Bad Team!\n"); } } return 0;}
阅读全文
0 0
- 【组合数学--拉姆齐定理】hdu 6152 Friend-Graph
- hdu 6152 Friend-Graph(拉姆齐定理)
- HDU 6152 Friend-Graph(拉姆齐定理+暴力)
- HDU 6152 Friend-Graph(定理)
- Hdu 6152 Friend-Graph(Ramsey定理)
- ramsey定理 : HDU-5917 Instability、 HDU-6152 Friend-Graph
- HDU6152 Friend-Graph 数学|签到|Ramsey定理
- HDU6152 Friend-Graph(拉姆齐定理)
- HDU 6152 Friend-Graph
- HDU 6152 Friend-Graph
- hdu-6152 Friend-Graph
- HDU 6152 Friend-Graph
- HDU 6152 Friend-Graph
- hdu 6152 Friend-Graph
- HDU-6152Friend-Graph
- HDU 6152 Friend-Graph
- hdu6152(拉姆齐(Ramsey)定理) Friend-Graph
- Hdu 6152 Friend-Graph【暴力】
- JavaScript实现的网页计算器功能
- [机器学习]信息&熵&信息增益
- Elasticsearch Nest聚合分组取最小值查询
- SpringMVC+Hibernate+Spring整合
- 使用原生sql写python
- 【组合数学--拉姆齐定理】hdu 6152 Friend-Graph
- window.onscroll兼容浏览器
- 脚本检查端口是否在用
- RecyclerView使用案例一之滑动冲突
- jPicture
- 动态加载html后,点击获取焦点
- c++初级 之 类的成员函数以及this指针使用
- Kettle7.1 无法连接sqlserver2014
- java打印乘法口诀表