hdu6152
来源:互联网 发布:淘宝联盟高佣金通过 编辑:程序博客网 时间:2024/06/10 16:16
Friend-Graph
Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 783 Accepted Submission(s): 414
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
141 1 00 01
Sample Output
Great Team!
题意:有n个人,不能有3个人互不认识,也不能有三个人对于其他两人都认识,这样为好的团队,否则为坏的团队。
思路:其实就是找三元环,要找两种三元环,一是在认识关系中的三元环,二是在其补集中(即不认识网络)寻找三元环。要使得一个网络和它的补集都没有三元环,就要对于每个图都尽量多使用边,这样就要尽量制造四元环,那如果一个点和另一个点有连线那么就要隔一个点再与那个点有连线来避免三元环,但当点多了之后会出现有相隔的两个点都与原来那个点没有连线,所以当点多到一定数目的时候是不行的。当点数为5的时候可以制造五元环,当点数大于等于6的时候必然存在三元环。
#include<iostream>#include<stdio.h>#include<string.h>using namespace std;int n;int map[10][10];int main(){int t;scanf("%d",&t);while(t--){memset(map,-1,sizeof(map));scanf("%d",&n);if(n>=6){int x;for(int i=0;i<n-1;i++){for(int j=i+1;j<n;j++)scanf("%d",&x);}printf("Bad Team!\n");continue;}else{int i;for(i=0;i<n-1;i++){for(int j=i+1;j<n;j++){scanf("%d",&map[i][j]);map[j][i]=map[i][j];}}for(i=0;i<n-1;i++){int j;for(j=i+1;j<n;j++){int flag=map[i][j];int k;for(k=0;k<n;k++){if(map[i][k]==flag&&map[j][k]==flag){//cout<<"asds "<<i<<' '<<j<<' '<<k<<endl;break;}}if(k<n)break;}if(j<n)break;}if(i==n-1)printf("Great Team!\n");elseprintf("Bad Team!\n");}}}
阅读全文
0 0
- hdu6152
- HDU6152 Friend-Graph【模拟】
- hdu6152 Friend-Graph
- HDU6152-Friend-Graph
- hdu6152暴力暴力!!!
- 【HDU6152 2017中国大学生程序设计竞赛
- HDU6152 Friend-Graph(拉姆齐定理)
- hdu6152(拉姆齐(Ramsey)定理) Friend-Graph
- HDU6152 Friend-Graph 数学|签到|Ramsey定理
- hdu6152 Friend-Graph CCPC网赛1003 Ramsey定理
- hdu6152-CCPC网络赛&思维&拉姆齐定理-Friend-Graph
- HDU6152 Friend-Graph(拉姆齐定理,2017中国大学生程序设计竞赛
- hdu6152 Friend-Graph (2017 ccpc 网络赛 (暴力 + 一个神奇的定理)
- C#性能优化黑科技(一)【反射】修改属性的快速方法
- 一种比较省内存的稀疏矩阵Python存储方案
- 数据结构编程笔记十:第三章 栈和队列 循环队列的实现
- 读书笔记_CLR.via.c#第五章_基元类型_引用类型_值类型
- 王爽 《汇编语言》 读书笔记 三 寄存器(内存访问)
- hdu6152
- xShell快捷键
- hadoop分布式安装
- 基于webpack的angluar2项目搭建
- 对测试转开发的一些想法
- 在android 上,使用Opencv3.0实现图像无缝拼接,Fast查找特征点,BruteForce进行匹配
- 读书笔记_CLR.via.c#第十四章_字符,字符串和文本处理
- MYSQL 最近知识总结(4)
- 编译、链接学习笔记(二)目标文件的构成