zoukankan      html  css  js  c++  java
  • 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.(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!
    ");
    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!
    ");
    33             else
    34                 printf("Bad Team!
    ");
    35         }
    36     }
    37     return 0;
    38 }
  • 相关阅读:
    Codevs 2597 团伙(并查集)
    Codevs 1074 食物链 2001年NOI全国竞赛
    Bzoj 3831 [Poi2014]Little Bird
    Codevs 4600 [NOI2015]程序自动分析
    Codevs 3287 货车运输 2013年NOIP全国联赛提高组(带权LCA+并查集+最大生成树)
    段落排版--中文字间距、字母间距
    段落排版--行间距(行高)
    段落排版--缩进
    文字排版--删除线
    文字排版--下划线
  • 原文地址:https://www.cnblogs.com/zllwxm123/p/7397349.html
Copyright © 2011-2022 走看看