HDU 6152 Friend-Graph

来源:互联网 发布:腾讯 知乎 编辑:程序博客网 时间:2024/06/14 03:31

 

2017中国大学生程序设计竞赛 - 网络选拔赛 


Friend-Graph

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


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
141 1 00 01
题目大意: 有 T 组数据; 每组数据输入 N ,接着是N-1行,第 i 行有 N-i 个数(只能为1 或者0 )如果是1,第i个人和第i+j个人是朋友,0则不是朋友。则如果有三个人或以上相互不是朋友或3个人以上相互是朋友,那么输出Bad Team!,否则输出Great Team!
题解:水题,边输入边判断,用flag标记是否出现Bad Team!的情况。
#include<iostream>using namespace std;int main(){    int t;    cin>>t;    while(t--)    {        int n;        cin>>n;        int flag=0;        for(int i=0;i<n-1;i++)        {            int num1=0,num2=0;            int m;            for(int j=i+1;j<n;j++)                {                    cin>>m;                    if(m==1)num1++;                    else num2++;                }                if(num1>=3||num2>=3)flag=1;        }        if(flag==1)cout<<"Bad Team!"<<endl;        else cout<<"Great Team!"<<endl;    }    return 0;}