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完全问题 有一个近似算法是说—每次选取度数最大 ...
随机推荐
- mac电脑上从终端命令行进入电脑里U盘目录下
一般Mac电脑上u盘都在 Volumes 目录下,所以进入u盘可按如下命令: cd /Volumes/u盘名称
- MySQL SQL Training
源于知乎:50道SQL练习题 一.表数据 1.学生表——Student ),Sname ),Sage )); ' , '赵雷' , '1990-01-01' , '男'); ' , '钱电' , '1 ...
- 第二讲,NT头文件格式,以及文件头格式
今天详解NT 头格式,以及文件头格式,以及作用, 关于DOS头文件格式,以及DOSStub昨天的博客已经写过了.主要是分散讲解.便于理解. 一丶最小PE的生成,以及标准PE的生成 ps: (如果直接学 ...
- 轻松入门CAS系列(1)-轻松看懂企业单点登录的解决方案
常见的企业应用情况 企业内部的信息化一般都是一个过程中的 ,起初企业为了部分管理的需要,会上线几个信息化系统:后来对这块慢慢重视,信息系统会越来越多.开始,只有一两个系统时,员工还好,靠脑袋还能记得住 ...
- spring——自动装配
语法:<bean id="..." class="..." autowire="byType"/> autowire属性取值如下 ...
- centos7 + postgresql10
mysql被黑惨了,换了个超复杂的密码都不行,黑客会删除你所有的自定义库,然后插一个warning表,让你给他汇比特币. 提醒大家放在在公网的DB,要非常注意数据的安全性,万一被勒索了,真是mmp了. ...
- vuex项目history模式下404问题的解决方案
在 ” etc/nginx/conf.d/ “路径下修改你的当前项目的conf文件 在location中添加,下文中加粗部分的代码,实现重写路径,以避免出现404. location / { roo ...
- Swagger学习(四、配置API文档的分组)
完整示例 代码结构 运行效果 SwaggerConfig.class @Configuration //变成配置文件 @EnableSwagger2 //开启swagger2 public class ...
- 安卓开发之利用XmlPullParser解析XML文件
package com.lidaochen.phonecall; import android.support.v7.app.AppCompatActivity; import android.os. ...
- springboot集成websocket的两种实现方式
WebSocket跟常规的http协议的区别和优缺点这里大概描述一下 一.websocket与http http协议是用在应用层的协议,他是基于tcp协议的,http协议建立链接也必须要有三次握手才能 ...