Try Again

HDU 6152 Friend-Graph

Friend-Graph

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

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!
 
Source
 有三个或者三个以上认识或者不认识,都为Bad Team! 暴力枚举即可,也可以先拉姆齐定律,在枚举。
在组合数学上,拉姆齐(Ramsey)定理是要解决以下的问题:要找这样一个最小的数n,使得n个人中必定有k个人相识或l个人互不相识。
拉姆齐定理的通俗表述:
6 个人中至少存在3人相互认识或者相互不认识。
该定理等价于证明这6个顶点的完全图的边,用红、蓝二色任意着色,必然至少存在一个红色边三角形,或蓝色边三角形。
注:这个定理以弗兰克·普伦普顿·拉姆齐命名,1930年他在论文On a Problem in Formal Logic[2](《形式逻辑上的一个问题》)证明了R(3,3)=6。
#include <iostream> 
#include <algorithm> 
#include <cstring> 
#include <cstdio>
#include <vector> 
#include <queue> 
#include <cstdlib> 
#include <iomanip>
#include <cmath>
#include <cassert>
#include <ctime> 
#include <map> 
#include <set> 
using namespace std; 
#define lowbit(x) (x&(-x)) 
#define max(x,y) (x>y?x:y) 
#define min(x,y) (x<y?x:y) 
#define MAX 100000000000000000 
#define MOD 1000000007
#define pi acos(-1.0) 
#define ei exp(1) 
#define PI 3.141592653589793238462
#define ios() ios::sync_with_stdio(false)
#define INF 1044266558
#define mem(a) (memset(a,0,sizeof(a)))
typedef long long ll;
bool g[3006][3006];
int t,n,x;
int main()
{
    scanf("%d",&t);
    while(t--)
    {
        mem(g);
        scanf("%d",&n);
        bool flag=true;
        for(int i=1;i<=n-1;i++)
        {
            for(int j=i+1;j<=n;j++)
            {
                scanf("%d",&x);
                g[i][j]=g[j][i]=x;
            }
        }
        for(int i=1;i<=n-2;i++)
        {
            for(int j=i+1;j<=n-1;j++)
            {
                for(int k=j+1;k<=n;k++)
                {
                    if((g[i][j] && g[i][k] && g[j][k]) || (!g[i][j] && !g[j][k] && !g[i][k])) flag=false;
                    if(!flag) goto k;
                }
            }
        }
        k:;
        puts(flag?"Great Team!":"Bad Team!");
    }
    return 0;
}

 

posted @ 2017-08-20 09:30  十年换你一句好久不见  阅读(236)  评论(0编辑  收藏  举报