Friend-Graph

Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 28    Accepted Submission(s): 15

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!
 

Source

 
三点不能成环,暴力判环
 //2017-08-19
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm> using namespace std; const int N = ;
bool G[N][N];
int n; void work(){
for(int i = ; i <= n; i++){
for(int j = i+; j <= n; j++){
if(G[i][j] == ){
for(int k = j+; k <= n; k++){
if(G[i][k] == && G[j][k] == ){
printf("Bad Team!\n");return;
}
}
}
if(G[i][j] == ){
for(int k = j+; k <= n; k++){
if(G[i][k] == && G[j][k] == ){
printf("Bad Team!\n");return;
}
}
}
}
}
printf("Great Team!\n");
} int main()
{
int T, a;
scanf("%d", &T);
while(T--){
scanf("%d", &n);
for(int i = ; i <= n-; i++){
for(int j = i+; j <= n; j++){
scanf("%d", &a);
G[j][i] = G[i][j] = a;
}
}
work();
} return ;
}

HDU6152的更多相关文章

  1. 图论&数学:拉姆齐(Ramsey)定理

    拉姆齐(Ramsey)定理是要解决以下的问题:要找这样一个最小的数n,使得n个人中必定有k个人相识或l个人互不相识 我们所知道的结论是这样的 6 个人中至少存在3人相互认识或者相互不认识. 该定理等价 ...

随机推荐

  1. GoLang学习之Golang数组

    Go语言数组 数组是Go语言编程中最常用的数据结构之一.顾名思义,数组就是指一系列同一类型数据的集合.数组中包含的每个数据被称为数组元素( element),一个数组包含的元素个数被称为数组的长度.需 ...

  2. C#6.0语言规范(十四) 枚举

    一个枚举类型是一个独特的值类型(值类型)声明一组命名的常量. 这个例子 enum Color { Red, Green, Blue } 声明了一个名为枚举类型Color与成员Red,Green和Blu ...

  3. java打包jar后,使之一直在linux上运行,不随终端退出而关闭

      nohup java -jar xxx.jar&

  4. 《deep sort》复现过程

    目录 1. 准备代码与数据 deep_sort开源代码 克隆到本地服务器 git clone https://github.com/nwojke/deep_sort.git 下载MOT16数据集(MO ...

  5. odoo开发笔记 -- odoo web机制浅析

    http://blog.csdn.net/M0relia/article/details/39025947

  6. DockPanel与GeckoFX、ChrominumFX、CefSharp结合使用问题

    在使用DockPanel与ChrominumFx时,当在以下条件下拖动窗体时,会发生ChromiumWebBrowser崩溃的情况,此种情况也会在DockPanel与GeckoFX或CefSharp结 ...

  7. opencv2函数学习之flip:实现图像翻转

    在opencv2中,flip函数用来进行图片的翻转,包括水平翻转,垂直翻转,以及水平垂直翻转. void flip(const Mat& src, Mat& dst, int flip ...

  8. CentOS7下搭建FastDfs(V5.11)+Keepalived分布式集群部署

    FastDfs介绍 http://kb.cnblogs.com/page/82280/ 1.准备 系统 CentOS7 最小化安装. #VIP虚拟IP 10.1.6.218 #Keepalived 1 ...

  9. 详解C#特性和反射(二)

    使用反射(Reflection)使得程序在运行过程中可以动态的获取对象或类型的类型信息,然后调用该类型的方法和构造函数,或访问和修改该类型的字段和属性:可以通过晚期绑定技术动态的创建类型的实例:可以获 ...

  10. MyCat配置文件详解--server.xml

    server.xml包含mycat的系统配置信息,它有两个标签,分别是user和system,掌握system标签的各项配置属性是mycat调优的关键. <?xml version=" ...