hdu 6152 Friend-Graph(ccpc)

Friend-Graph

Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)


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  i th 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

题意:公司要测试自己的团队是好团队还是坏团队 所以调查了一下员工之间的关系 如果三个员工之间都互相认识或者都互相不认识就是坏团队 反之就是好团队(感觉这老板也是可以的 团队间太生疏了工作配和不来 太熟了会推翻老板?) 

刚开始做的时候就感觉这道题应该是有规律的 但是看了看时间和数据 感觉暴力应该可以过 交了一发 果然卡过了 然后就再没去看 结果比赛快结束了出题方改了时间 这就很尴尬了 赶奔没时间取做了 后来百度看了一下 发现了组合数学里拉姆塞定理

拉姆齐定理的通俗表述
6 个人中至少存在3人相互认识或者相互不认识。
该定理等价于证明这6个顶点的完全图的边,用红、蓝二色任意着色,必然至少存在一个红色边三角形,或蓝色边三角形。
注:这个定理以弗兰克·普伦普顿·拉姆齐命名,1930年他在论文On a Problem in Formal Logic[2](《形式逻辑上的一个问题》)证明了R(3,3)=6。
R(3,3)=6
证明如下:首先,把这6个人设为A、B、C、D、E、F六个点。由A点可以引出AB、AC、AD、AE、AF五条 线段。设:如果两个人认识,则设这两个人组成的线段为红色;如果两个人不认识,则设这两个人组成的线段为蓝色。
抽屉原理可知:这五条线段中至少有三条是同色的。不妨设AB、AC、AD为红色。若BC或CD为红色,则结论显然成立。若BC和CD均为蓝色,则若BD为红色,则一定有三个人相互认识;若BD为蓝色,则一定有三个人互相不认识。

ac代码:
#include<bits/stdc++.h>
using namespace std;
int T,n;
int main()
{
    scanf("%d",&T);
    while(T--)
    {
        scanf("%d",&n);

            int a[10][10]={0};
            for(int i=1; i<n; ++i)
                for(int j=i+1; j<=n; ++j)
                {
                    int t;
                    scanf("%d",&t);
                    if(t&&n<6) a[i][j]=a[j][i]=1;
                }
                if(n>=6)
                {
                    puts("Bad Team!");
                    continue;
                }
                int f=0;
                for(int i=1;i<=n;++i)
                for(int j=i+1;j<=n;++j)
                for(int k=j+1;k<=n;++k)
                if(a[i][j]&&a[i][k]&&a[j][k])
                {
                    f=1;
                    break;
                }
                if(f==1)
                    printf("Bad Team!\n");
                else
                    printf("Great Team!\n");
    }
    return 0;
}


、、、

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值