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中国大学生程序设计竞赛 - 网络选拔赛的更多相关文章

  1. HDU 6154 - CaoHaha's staff | 2017 中国大学生程序设计竞赛 - 网络选拔赛

    /* HDU 6154 - CaoHaha's staff [ 构造,贪心 ] | 2017 中国大学生程序设计竞赛 - 网络选拔赛 题意: 整点图,每条线只能连每个方格的边或者对角线 问面积大于n的 ...

  2. HDU 6150 - Vertex Cover | 2017 中国大学生程序设计竞赛 - 网络选拔赛

    思路来自 ICPCCamp /* HDU 6150 - Vertex Cover [ 构造 ] | 2017 中国大学生程序设计竞赛 - 网络选拔赛 题意: 给了你一个贪心法找最小覆盖的算法,构造一组 ...

  3. HDU 6156 - Palindrome Function [ 数位DP ] | 2017 中国大学生程序设计竞赛 - 网络选拔赛

    普通的数位DP计算回文串个数 /* HDU 6156 - Palindrome Function [ 数位DP ] | 2017 中国大学生程序设计竞赛 - 网络选拔赛 2-36进制下回文串个数 */ ...

  4. HDU 6154 CaoHaha's staff(2017中国大学生程序设计竞赛 - 网络选拔赛)

    题目代号:HDU 6154 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6154 CaoHaha's staff Time Limit: 2000/1 ...

  5. 2017中国大学生程序设计竞赛 - 网络选拔赛 HDU 6152 Friend-Graph(暴力搜索)

    题目传送:http://acm.hdu.edu.cn/showproblem.php?pid=6152 Problem Description It is well known that small ...

  6. 2017中国大学生程序设计竞赛 - 网络选拔赛 HDU 6152 Friend-Graph 暴暴暴暴力

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6152 题意:判定一个无向图是否有三个点的团或者三个点的独立集. 解法:Ramsey theorem,n ...

  7. 2017中国大学生程序设计竞赛 - 网络选拔赛 1003 HDU 6152 Friend-Graph (模拟)

    题目链接 Problem Description It is well known that small groups are not conducive of the development of ...

  8. 2017中国大学生程序设计竞赛 - 网络选拔赛 HDU 6155 Subsequence Count 矩阵快速幂

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6155 题意: 题解来自:http://www.cnblogs.com/iRedBean/p/73982 ...

  9. 2017中国大学生程序设计竞赛 - 网络选拔赛 HDU 6150 Vertex Cover 二分图,构造

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6150 题意:"最小点覆盖集"是个NP完全问题 有一个近似算法是说—每次选取度数最大 ...

随机推荐

  1. Python 【Debug排除程序故障】

    debug #排除程序故障 print()函数常和#号注释结合在一起用来debug 多行注释有两种快捷操作:1.在需要注释的多行代码块前后加一组三引号''' 2.选中代码后使用快捷键操作:Window ...

  2. python — lambda表达式与内置函数

    目录 1 lambda表达式 (匿名函数) 2 内置函数 1 lambda表达式 (匿名函数) 用于表示简单的函数 lambda表达式,为了解决简单函数的情况: def func(a1,a2): == ...

  3. Git安装使用秘籍

    首先Git的功能,是用于帮助用户实现版本控制的软件,GIT一般和GitHub配套使用.Git是个软件,GitHub是个网站,它们的关系就像雷锋与雷峰塔一样,没什么关系.本文只提供Git安装方法,其它请 ...

  4. .Net下二进制形式的文件存储与读取

    .Net下图片的常见存储与读取凡是有以下几种:存储图片:以二进制的形式存储图片时,要把数据库中的字段设置为Image数据类型(SQL Server),存储的数据是Byte[].1.参数是图片路径:返回 ...

  5. Qt使用自带的windeployqt 查找生成exe 必需的库文件

    集成开发环境 QtCreator 目前生成图形界面程序 exe 大致可以分为两类:Qt Widgets Application  和 Qt Quick Application.下面分别介绍这两类exe ...

  6. ES6的拓展

    1.String的拓展 ① str.includes("abc"); ② str.startWith("abc"); ③ str.endWith("a ...

  7. Dubbo 配置参数

    关闭启动检查 在dubbo多模块项目启动的时候为了并行启动多个服务,缩短启动时间,需要解除模块之间的依赖检测 dubbo.consumer.check=false @Reference(check = ...

  8. 7.移动端自动化测试-小知识 try...except...finally语句

    异常Error 我们在写代码的时候,经常会遇见程序抛出Error无法执行的情况 一般情况下,在Python无法正常处理程序时就会发生一个异常.异常是Python对象,表示一个错误.当Python脚本发 ...

  9. static成员函数和static成员

    C++的静态成员是和类关联的,它属于某个类,但是不属于某个特定的对象.静态成员变量只存储一份供所有对象共用.所以在所有对象中都可以共享它.使用静态成员变量实现多个对象之间的数据共享不会破坏隐藏的原则, ...

  10. 《浏览器工作原理与实践》<03>HTTP请求流程:为什么很多站点第二次打开速度会很快?

    一个 TCP 连接过程包括了建立连接.传输数据和断开连接三个阶段. 而 HTTP 协议,正是建立在 TCP 连接基础之上的.HTTP 是一种允许浏览器向服务器获取资源的协议,是 Web 的基础,通常由 ...