Friend-Graph (HDU 6152)2017中国大学生程序设计竞赛 - 网络选拔赛
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!
题解:Team中有3个或者3个以上不是朋友或者是朋友,都输出Bad,其他输出Great。
/** By Mercury_Lc */
#include <bits/stdc++.h>
using namespace std;
int a[3005][3005];
int main()
{
int t,i,j,k,n,f;
scanf("%d",&t);
while(t--)
{
f = 0;
scanf("%d",&n);
for(i = 1; i <= n; i ++)
{
for(j = i + 1; j <= n; j ++)
{
scanf("%d",&a[i][j]);
}
}
for(i = 1; i <= n; i ++) //暴力搜索
{
for(j = i + 1; j <= n; j ++)
{
if(a[i][j]) // 是朋友关系,继续判断这两个人有没有共同朋友
{
for(k = j + 1; k <= n; k ++)
{
if(a[i][k] && a[j][k])
{
f = 1;
break;
}
}
}
else // 不是朋友关系,继续判断这两个人有没有共同朋友
{
for(k = j + 1; k <= n; k ++)
{
if(a[i][k] == 0 && a[j][k] == 0)
{
f = 1;
break;
}
}
}
if(f)break;
}
if(f)break;
}
if(f)printf("Bad Team!\n");
else printf("Great Team!\n");
}
return 0;
}
Friend-Graph (HDU 6152)2017中国大学生程序设计竞赛 - 网络选拔赛的更多相关文章
- HDU 6154 - CaoHaha's staff | 2017 中国大学生程序设计竞赛 - 网络选拔赛
/* HDU 6154 - CaoHaha's staff [ 构造,贪心 ] | 2017 中国大学生程序设计竞赛 - 网络选拔赛 题意: 整点图,每条线只能连每个方格的边或者对角线 问面积大于n的 ...
- HDU 6150 - Vertex Cover | 2017 中国大学生程序设计竞赛 - 网络选拔赛
思路来自 ICPCCamp /* HDU 6150 - Vertex Cover [ 构造 ] | 2017 中国大学生程序设计竞赛 - 网络选拔赛 题意: 给了你一个贪心法找最小覆盖的算法,构造一组 ...
- HDU 6156 - Palindrome Function [ 数位DP ] | 2017 中国大学生程序设计竞赛 - 网络选拔赛
普通的数位DP计算回文串个数 /* HDU 6156 - Palindrome Function [ 数位DP ] | 2017 中国大学生程序设计竞赛 - 网络选拔赛 2-36进制下回文串个数 */ ...
- HDU 6154 CaoHaha's staff(2017中国大学生程序设计竞赛 - 网络选拔赛)
题目代号:HDU 6154 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6154 CaoHaha's staff Time Limit: 2000/1 ...
- 2017中国大学生程序设计竞赛 - 网络选拔赛 HDU 6152 Friend-Graph(暴力搜索)
题目传送:http://acm.hdu.edu.cn/showproblem.php?pid=6152 Problem Description It is well known that small ...
- 2017中国大学生程序设计竞赛 - 网络选拔赛 HDU 6152 Friend-Graph 暴暴暴暴力
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6152 题意:判定一个无向图是否有三个点的团或者三个点的独立集. 解法:Ramsey theorem,n ...
- 2017中国大学生程序设计竞赛 - 网络选拔赛 1003 HDU 6152 Friend-Graph (模拟)
题目链接 Problem Description It is well known that small groups are not conducive of the development of ...
- 2017中国大学生程序设计竞赛 - 网络选拔赛 HDU 6155 Subsequence Count 矩阵快速幂
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6155 题意: 题解来自:http://www.cnblogs.com/iRedBean/p/73982 ...
- 2017中国大学生程序设计竞赛 - 网络选拔赛 HDU 6150 Vertex Cover 二分图,构造
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6150 题意:"最小点覆盖集"是个NP完全问题 有一个近似算法是说—每次选取度数最大 ...
随机推荐
- VS2017生成一个简单的DLL文件 和 LIB文件——C语言
下面我们将用两种不同的姿势来用VS2017生成dll文件(动态库文件)和lib文件(静态库文件),这里以C语言为例,用最简单的例子,来让读者了解如何生成dll文件(动态库文件) 生成动态库文件 姿势一 ...
- Wannafly挑战赛2D Delete (最短路好题)
大意: 给定DAG, 给定点$S,T$, 每次询问给出点$x$, 求删除$x$后的$S->T$的最短路, 询问之间独立. 删除点$x$的最短路一定要经过一条边$(u,v)$, 满足$u$拓扑序在 ...
- 一个复杂关联的sql
在项目中遇到了一个比较复杂关系的sql,关联关系有些模糊,现在梳理一下 sql如下: SELECT TRAN.TRANS_DATE, TRAN.TRANS_TIME, TRAN.BUSI_TRAC_C ...
- eclipse导入maven空项目,eclipse导入时不识别maven项目
经常我们在网上下载的一些开源项目中,想要导入eclipse中,却发现eclipse不识别这个项目,这时候怎么办呢? 解决办法多种多样,我这里举例出最实用的2种: 1.在项目的根目录中加入.classp ...
- 怎样理解xhr.overrideMimeType()和xhr.responseType
一般情况下, 我们会通过 xhr.responseType 告诉服务器我们想要什么类型的返回数据. 然后xhr.response 会根据xhr.responseType属性值来自动解析返回值. 但有时 ...
- 电脑无法上网,DNS出现fec0:0:0:ffff::1%1问题
具体描述:qq,微信可用网,但其他不能用. 一.win+r 输入cmd 打开命令行:ipconfig /all 查看DNS 二.打开文本编辑器,输入如下文本: @Echo onpushd\window ...
- 5.移动端自动化测试-小知识 import和from...import的区别
一.import 1 import导入的时,需要使用模块名的限定. 举个例子,我们首先创建一个md.py文件,里面有一个函数 2 然后在1.py文件中引用这个函数. 注意,我们需要使用md.的方式 ...
- JAVA线程池例子
用途及用法 网络请求通常有两种形式:第一种,请求不是很频繁,而且每次连接后会保持相当一段时间来读数据或者写数据,最后断开,如文件下载,网络流媒体等.另 一种形式是请求频繁,但是连接上以后读/写很少量的 ...
- Django—处理流程
用户通过浏览器发送请求 请求到达request中间件,中间件对request请求做预处理或者直接返回response 若未返回response,会到达urlconf路由,找到对应视图函数 视图函数做相 ...
- STM32F407 CAN发送注意事项
STM32使用的baseCAN,使用过程中发现一些注意的事项,特此记录. 现象: CAN发送程序,在1ms以上间隔调用时,一切正常. 当连续调用CAN发送程序4次或更多时,表现为丢数据,仅能发送一条或 ...