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.(n3000)
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
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.(n3000)
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;}
阅读全文
0 0
- ccpc网络赛Friend-Graph
- [ccpc网络赛]Friend-Graph
- 2017 ccpc 网络赛 Friend-Graph
- hdu5152.Friend-Graph(CCPC网络赛)
- 2017ccpc网络赛 1003Friend-Graph
- hdu6152-CCPC网络赛&思维&拉姆齐定理-Friend-Graph
- 2017ccpc网络赛——Friend-Graph
- 2017CCPC网络选拔赛1003Friend-Graph
- 2017CCPC 网络选拔赛 1003 Friend-Graph
- 2017CCPC网络选拔赛 1003-Friend-Graph
- hdu6152 Friend-Graph (2017 ccpc 网络赛 (暴力 + 一个神奇的定理)
- 2017CCPC网络赛 Friend-Graph(暴力、拉姆齐(Ramsey)定理)
- ccpc预选赛-1003Friend-Graph
- HDU 6152-Friend-Graph(ccpc)
- 2017ccpc网赛-1003-Friend-Graph
- hdu 6152 Friend-Graph(ccpc)
- HDU 6152 Friend-Graph(2017CCPC网络选拔赛)【Floyed求传递闭包】
- CCPC网赛 Friend-Graph(图论+模拟+输入外挂)
- JDBC之连接池: Tomcat 8.5 MySQL数据库连接池的配置与使用
- Idea设置自定义类的注释
- JavaScript中window.location对象介绍
- springmvc+mybatis多数据源分布式事务管理
- springmvc----参数绑定
- ccpc网络赛Friend-Graph
- Python将两个数组合并成一个数组,多维数组变成一维数组
- Python爬数据
- 似是而非的JS
- 机器学习笔试题
- netty(八)源码分析之eventLoop和eventLoopGroup
- 百度编辑器使用随记
- 如何终止java线程
- DB主从一致性架构优化4种方法