• 2017中国大学生程序设计竞赛


    题目传送:http://acm.hdu.edu.cn/showproblem.php?pid=6152

    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!

    题解:暴搜可以过,因为时间给的多。

    然后保存的数组类型不是int是bool,要不然会MLE。

    其实也可以发现当点数大于等于6的时候,都是bad team了。

     1 #include <iostream>
     2 #include<bits/stdc++.h>
     3 using namespace std;
     4 
     5 bool a[3002][3002];//评论提醒只需a[7][7]即可
     6 int t,n;
     7 
     8 bool work()
     9 {
    10    for(int i=1;i<=n;i++)
    11    {
    12        for(int j=i+1;j<=n;j++)
    13         if(a[i][j]==1)
    14         {
    15             for(int k=j+1;k<=n;k++)
    16                 if (a[j][k]==1 && a[k][i]==1) return 0;
    17         } else
    18         {
    19             for(int k=j+1;k<=n;k++)
    20                 if(a[j][k]==0 && a[k][i]==0) return 0;
    21         }
    22    }
    23    return 1;
    24 }
    25 
    26 int main()
    27 {
    28     scanf("%d",&t);
    29     while(t--)
    30     {
    31         scanf("%d",&n);
    32         for(int i=1;i<=n;i++)
    33         {
    34             for(int j=1;j<=n-i;j++)
    35             {
    36                 int x;
    37                 scanf("%d",&x);
    38                 a[i][i+j]=x;
    39                 a[i+j][i]=x;
    40             }
    41         }
    42         if (n>6) {printf("Bad Team!
    "); continue;}
    43       if(work()) printf("Great Team!
    ");
    44         else printf("Bad Team!
    ");
    45     }
    46   return 0;
    47 }
  • 相关阅读:
    html JS 打开本地程序及文件
    [转]jquery mobile中redirect重定向问题
    kafka中broker、producer、consumer主要配置参数说明
    手写一个LruCache
    ES发布时max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144] 错误
    UML类图
    JVM调优总结
    JVM学习系列(五) 常见的JVM参数
    JVM学习系列(四) 相关概念
    JVM学习系列(三) 虚拟机监控相关
  • 原文地址:https://www.cnblogs.com/Annetree/p/7403920.html
Copyright © 2020-2023  润新知