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完全问题 有一个近似算法是说—每次选取度数最大 ...
随机推荐
- Wannafly挑战赛23
B. 游戏 大意: $n$堆石子, 第$i$堆初始$a_i$, 每次只能选一堆, 假设一堆个数$x$, 只能取$x$的约数, 求先手第一步必胜取法. SG入门题, 预处理出所有$SG$值. 先手要必胜 ...
- 安装gcc过程中遇到相互依赖的问题
在离线安装gcc的时候需要安装一些包,但是在安装 glibc-common glibc遇到一个很恶心的问题,这两个包相互依赖. 经查询才发现需要一起安装这两个依赖包.真是有趣的很 rpm -iv ...
- 怎样创建一个canvas画布环境
1. 由于canvas画布在网页中, 所以需要在html中添加canvas标签: <!DOCTYPE html> <html lang="en"> < ...
- java7:核心技术与最佳实践读书笔记——对象生命周期
流程:字节码文件(.class) -> 类加载 -> 类链接 -> 类初始化 -> 对象初始化 -> 对象创建 -> 对象使用 -> 对象回收 . 1.Jav ...
- iview表单验证数字
验证输入字符串必须为数字 html: <FormItem label="兑换积分:" prop="exchangeIntegral"> <In ...
- 调用打码平台api获取验证码 (C#版)
一.打码平台很多,这里选择两个:联众和斐斐 联众开发文档: https://www.jsdati.com/docs/guide 斐斐开发文档: http://docs.fateadm.com/web/ ...
- 很low的四位验证码实现
<html> <head> <meta charset="utf-8"> </head> <body> <inpu ...
- chrome浏览器重新安装不了
1.打开注册表方法1. windows键 + R-->输入regedit-->回车方法2.开始-运行里输入regedit方法3.单击任务栏中windows图标,在搜索程序和文件中输入reg ...
- 如何从零搭建hexo个人博客网站
https://www.jianshu.com/p/adf65cbad393?utm_source=oschina-app 准备工作 github账号 node.js 环境搭建 git使用 mar ...
- 三、DQL语言
目录 一.基础查询 (一)语法 (二)特点 (三)示例 二.条件查询 (一)语法 (二)筛选条件的分类 三.排序查询 (一)语法 (二)特点 四.常见函数 (一)介绍 (二)分类 五.单行函数 (一) ...