码迷,mamicode.com
首页 > 其他好文 > 详细

Friend-Graph

时间:2017-08-19 19:58:59      阅读:153      评论:0      收藏:0      [点我收藏+]

标签:1.0   memory   size   sample   eth   return   pad   std   class   

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.(n3000)

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 }

 

Friend-Graph

标签:1.0   memory   size   sample   eth   return   pad   std   class   

原文地址:http://www.cnblogs.com/zllwxm123/p/7397349.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!