Friend-Graph

Friend-Graph

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

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!

这道题当时题意是猜的自己真的没看懂,英语太烦了.

 1 #include <bits/stdc++.h>
 2 using namespace std;
 3 int num[3010];
 4 int main(){
 5     int T;
 6     scanf("%d",&T);
 7     while(T--){
 8         int n;
 9         scanf("%d",&n);
10         bool prime=true;
11         if(n>5)
12             prime=false;
13         int m;
14         memset(num,0,sizeof(num));
15         for(int i=1;i<n;i++){
16                 for(int j=1;j<=n-i;j++){
17                         scanf("%d",&m);
18                         if(m==1){
19                                 num[i]++;
20                                 num[i+j]++;
21                         }
22                 }
23         }
24         if(!prime)
25             printf("Bad Team!\n");
26         else{
27             for(int i=1;i<=n;i++){
28                     if(num[i]>=3||(n-1-num[i])>=3)
29                         prime=false;
30             }
31             if(prime)
32                 printf("Great Team!\n");
33             else
34                 printf("Bad Team!\n");
35         }
36     }
37     return 0;
38 }
时间: 2024-11-20 22:18:03

Friend-Graph的相关文章

Codeforces 841D Leha and another game about graph - 差分

Leha plays a computer game, where is on each level is given a connected graph with n vertices and m edges. Graph can contain multiple edges, but can not contain self loops. Each vertex has an integer di, which can be equal to 0, 1 or  - 1. To pass th

724G - Xor-matic Number of the Graph(线性基)

724G - Xor-matic Number of the Graph 题意: 待补~~ 参考http://www.cnblogs.com/ljh2000-jump/p/6443189.html

[CodeChef - GERALD07 ] Chef and Graph Queries

Read problems statements in Mandarin Chineseand Russian. Problem Statement Chef has a undirected graph G. This graph consists of N vertices and M edges. Each vertex of the graph has an unique index from 1 to N, also each edge of the graph has an uniq

HDOJ 5409 CRB and Graph 无向图缩块

无向图缩块后,以n所在的块为根节点,dp找每块中的最大值. 对于每一个桥的答案为两块中的较小的最大值和较小的最大值加1 CRB and Graph Time Limit: 8000/4000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 113    Accepted Submission(s): 41 Problem Description A connected, undi

【Lintcode】137.Clone Graph

题目: Clone an undirected graph. Each node in the graph contains a label and a list of its neighbors. How we serialize an undirected graph: Nodes are labeled uniquely. We use # as a separator for each node, and , as a separator for node label and each

133. Clone Graph

题目: Clone an undirected graph. Each node in the graph contains a label and a list of its neighbors. OJ's undirected graph serialization: Nodes are labeled uniquely. We use # as a separator for each node, and , as a separator for node label and each n

图像分割之(二)Graph Cut(图割)

[email protected] http://blog.csdn.net/zouxy09 上一文对主要的分割方法做了一个概述.那下面我们对其中几个比较感兴趣的算法做个学习.下面主要是Graph Cut,下一个博文我们再学习下Grab Cut,两者都是基于图论的分割方法.另外OpenCV实现了Grab Cut,具体的源码解读见博文更新.接触时间有限,若有错误,还望各位前辈指正,谢谢. Graph cuts是一种十分有用和流行的能量优化算法,在计算机视觉领域普遍应用于前背景分割(Image se

Tensorflow学习笔记2:About Session, Graph, Operation and Tensor

简介 上一篇笔记:Tensorflow学习笔记1:Get Started 我们谈到Tensorflow是基于图(Graph)的计算系统.而图的节点则是由操作(Operation)来构成的,而图的各个节点之间则是由张量(Tensor)作为边来连接在一起的.所以Tensorflow的计算过程就是一个Tensor流图.Tensorflow的图则是必须在一个Session中来计算.这篇笔记来大致介绍一下Session.Graph.Operation和Tensor. Session Session提供了O

codeforces 715B:Complete The Graph

Description ZS the Coder has drawn an undirected graph of n vertices numbered from 0 to n - 1 and m edges between them. Each edge of the graph is weighted, each weight is a positive integer. The next day, ZS the Coder realized that some of the weight

分析函数调用关系图(call graph)的几种方法

分析函数调用关系图(call graph)的几种方法 绘制函数调用关系图对理解大型程序大有帮助.我想大家都有过一边读源码(并在头脑中维护一个调用栈),一边在纸上画函数调用关系,然后整理成图的经历.如果运气好一点,借助调试器的单步跟踪功能和call stack窗口,能节约一些脑力.不过如果要分析的是脚本语言的代码,那多半只好老老实实用第一种方法了.如果在读代码之前,手边就有一份调用图,岂不妙哉?下面举出我知道的几种免费的分析C/C++函数调用关系的工具. 函数调用关系图(call graph)是图