HDU6152
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
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 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
Sample Input
4
1 1 0
0 0
1
Sample Output
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的更多相关文章
- 图论&数学:拉姆齐(Ramsey)定理
拉姆齐(Ramsey)定理是要解决以下的问题:要找这样一个最小的数n,使得n个人中必定有k个人相识或l个人互不相识 我们所知道的结论是这样的 6 个人中至少存在3人相互认识或者相互不认识. 该定理等价 ...
随机推荐
- javascript数据结构与算法---检索算法(顺序查找、最大最小值、自组织查询)
javascript数据结构与算法---检索算法(顺序查找.最大最小值.自组织查询) 一.顺序查找法 /* * 顺序查找法 * * 顺序查找法只要从列表的第一个元素开始循环,然后逐个与要查找的数据进行 ...
- android studio 一直卡在Gradle:Build Running的解决办法
转:android studio 一直卡在Gradle:Build Running的解决办法 在使用AS开发安卓应用程序的时候经常会遇到Gradle build running一直在运行甚至卡死的 ...
- Bash数组
1. 数组申明 declare -a array 2. 数组赋值 #法1 array=(var1 var2 var3 ... varN) #法2 array=([]=var1 []=var2 []=v ...
- sftp命令不被识别
sftp命令不被识别 原因:C:\Windows\System32文件夹下面没有sftp可执行程序 解决方案:安装openssh,安装完成之后可发现在path系统变量的值中多了openssh的安装目录 ...
- 使用控制台程序搭建OAuth授权服务器
参考地址:ASP.NET Web Api: Understanding OWIN/Katana Authentication/Authorization Part I: Concepts 先上一张OA ...
- 常见数据结构的Java实现
单链表的Java实现 首先参考wiki上的单链表说明,单链表每个节点包含数据和指向链表中下一个节点的指针或引用.然后看代码 import java.lang.*; public class Singl ...
- Android 开发工具类 37_ ContactInfoProvider
Android 手机中的联系人信息保存在 data\data\com.android.providers.contacts\databases\contacts2.db 中.主要有 raw_cont ...
- 修改wireshark协议解析规则
不同的协议有不同的解码器,wireshark尝试为每个包尝试找到正确的解码器,特定的情况有可能会选择错误的解码器. 1.使用了其它协议的标准端口,被错误解码,使用udp的80端口发送数据被当作QUIC ...
- 本地主机访问不了nginx 页面,请求超时
虚拟机可以正常访问nginx页面,但是电脑浏览器访问不了,一番排差,防火墙的问题. /etc/init.d/iptables stop
- Python虚拟环境工具-Virtualenv 介绍及部署记录
在开发Python应用程序时,系统默认的Python版本可能会不兼容这个应用程序, 如果同时开发多个应用程序, 可能会用到好几个版本的python环境, 这种情况下,每个应用可能需要各自拥有一套&qu ...