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. PHP中eval函数的危害与正确禁用方法

    其实 eval()是无法用php.ini中的 disable_functions禁止掉的 :eval是zend的,因此不是PHP_FUNCTION 函数: 如果想禁掉eval可以用php的扩展 Suh ...

  2. 试着用java实现DNS(一)——DatagramSocket, DatagramPacket, Message

    一般来说,自己编写DNS是没有必要的,目前开源的dns服务软件很多,功能也很强大.但是,有时候又是很有必要的,有着诸多好处.比如说,用于企业内网,简化DNS配置,可以根据企业需求添加新的功能,非常灵活 ...

  3. 对"某V皮"N服务器节点的一次后渗透测试

    i春秋作家:jasonx 前言:由于这个VPN节点服务器是之前拿到的,一直没时间做进一步渗透,昨天看到我蛋总表哥发红包,然后我运气爆表抢了个运气王,再加上好久没发文章了,所以就抽空测试下咯. 0×01 ...

  4. javascript window对象属性和方法

    window对象 window对象表示一个浏览器窗口或一个框架.在客户端JavaScript中,window对象是全局对象,所有的表达式 都在当前的环境中计算.也就是说,要引用当前窗口根本不需要特殊的 ...

  5. iOS开发-带Placeholder的UITextView实现

    iOS中UITextField带有PlaceHolder属性,可以方便用于提示输入.但是同样可以进行文本输入的UITextView控件则没有PlaceHolder属性,还是有些不方便的,尤其是对于略带 ...

  6. SpringMVC初探-HelloWorld

    MVC的概念 MVC是一种设计模式,即Model--View-Controller,模型--视图--控制器 Model(模型)表示应用程序核心(比如数据库记录列表). View(视图)显示数据(数据库 ...

  7. [Spring]IOC控制反转和DI依赖注入

    从之前算起到现在接触Spring也已经有几天了,进度也不是很快,就只弄懂了控制反转和依赖注入那么一点东西.然后敲了两个demo 主要是因为之前没有学过,然后网上资源很多但是都不是面向我们初学者的,大多 ...

  8. 线程中的读写锁ReadWriteLock

    Lock锁还有两个非常强大的类 ReadWriteLock接口实现类ReentrantReadWriteLock(非常重要的锁) 想实现 读取的时候允许多线程并发访问,写入的时候不允许. 这种效果.. ...

  9. PLSQL Developer概念学习系列之登录连接Oracle时出现(没有登录) -PL / SQL Developer:ORA - 12541: TNS :无建听程序的错误解决办法(图文详解)

    不多说,直接上干货! 前期博客 PLSQL Developer概念学习系列之如何正确登录连接上Oracle(图文详解)   如用scott.scott_password进行登录,orcl是全局数据库 ...

  10. TensorFlow的梯度裁剪

    在较深的网络,如多层CNN或者非常长的RNN,由于求导的链式法则,有可能会出现梯度消失(Gradient Vanishing)或梯度爆炸(Gradient Exploding )的问题. 原理 问题: ...