• linkedu视频
  • 平面设计
  • 电脑入门
  • 操作系统
  • 办公应用
  • 电脑硬件
  • 动画设计
  • 3D设计
  • 网页设计
  • CAD设计
  • 影音处理
  • 数据库
  • 程序设计
  • 认证考试
  • 信息管理
  • 信息安全
菜单
linkedu.com
  • 网页制作
  • 数据库
  • 程序设计
  • 操作系统
  • CMS教程
  • 游戏攻略
  • 脚本语言
  • 平面设计
  • 软件教程
  • 网络安全
  • 电脑知识
  • 服务器
  • 视频教程
  • JavaScript
  • ASP.NET
  • PHP
  • 正则表达式
  • AJAX
  • JSP
  • ASP
  • Flex
  • XML
  • 编程技巧
  • Android
  • swift
  • C#教程
  • vb
  • vb.net
  • C语言
  • Java
  • Delphi
  • 易语言
  • vc/mfc
  • 嵌入式开发
  • 游戏开发
  • ios
  • 编程问答
  • 汇编语言
  • 微信小程序
  • 数据结构
  • OpenGL
  • 架构设计
  • qt
  • 微信公众号
您的位置:首页 > 程序设计 >C语言 > [ccpc网络赛]Friend-Graph

[ccpc网络赛]Friend-Graph

作者:你那么爱笑,家里人知道吗? 字体:[增加 减小] 来源:互联网 时间:2017-08-27

你那么爱笑,家里人知道吗?通过本文主要向大家介绍了ccpc等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com

Friend-Graph

 

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


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.(n≤3000)

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


 

 

 

 

可直接暴力枚举,也可用拉姆齐(Ramsey)定理

在组合数学上,拉姆齐(Ramsey)定理是要解决以下的问题:要找这样一个最小的数n,使得n个人中必定有k个人相识或l个人互不相识。 
拉姆齐定理的通俗表述: 
6 个人中至少存在3人相互认识或者相互不认识。 
该定理等价于证明这6个顶点的完全图的边,用红、蓝二色任意着色,必然至少存在一个红色边三角形,或蓝色边三角形。 
注:这个定理以弗兰克·普伦普顿·拉姆齐命名,1930年他在论文On a Problem in Formal Logic[2](《形式逻辑上的一个问题》)证明了R(3,3)=6。

 

 

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <climits>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <list>
#define rep(i,m,n) for(int i=m;i<=n;i++)
#define rsp(it,s) for(set<int>::iterator it=s.begin();it!=s.end();it++)
const int inf_int = 2e9;
const long long inf_ll = 2e18;
#define inf_add 0x3f3f3f3f
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pi acos(-1.0)
#define pii pair<int,int>
#define Lson L, mid, rt<<1
#define Rson mid+1, R, rt<<1|1
const int maxn=5e2+10;
using namespace std;
typedef  vector<int> vi;
typedef  long long ll;
typedef  unsigned long long  ull;
inline int read(){int ra,fh;char rx;rx=getchar(),ra=0,fh=1;
while((rx<'0'||rx>'9')&&rx!='-')rx=getchar();if(rx=='-')
fh=-1,rx=getchar();while(rx>='0'&&rx<='9')ra*=10,ra+=rx-48,
rx=getchar();return ra*fh;}

//#pragma comment(linker, "/STACK:102400000,102400000")
ll gcd(ll p,ll q){return q==0?p:gcd(q,p%q);}
ll qpow(ll p,ll q){ll f=1;while(q){if(q&1)f=f*p;p=p*p;q>>=1;}return f;}
int dir[4][2]={{-1,0},{1,0},{0,-1},{0,1}};

const int N = 3005;


int T,n;
int fl;
int t;
int main()
{
    ios_base::sync_with_stdio(false);
//    freopen("data.txt","r",stdin);
    cin >>T;
    for(int k=0;k<T;k++)
    {
        fl = 0;
        cin >> n;
        if(n>6)
        {
            cout <<"Bad Team!"<<endl;
            continue;
        }
        int a,b;
        for(int i=1;i<=n-1;i++)
        {
            a=b=0;
            for(int j=i+1;j<=n;j++)
            {
                cin >> t;
                if(t)
                {
                    a++;
                }
                else
                {
                    b++;
                }
            }
            if(a>=3||b>=3) fl = 1;
        }

        if(fl)
        {
            cout <<"Bad Team!"<<endl;
        }
        else
        {
            cout <<"Great Team!"<<endl;
        }
    }

    return 0;
}



 

 

分享到:QQ空间新浪微博腾讯微博微信百度贴吧QQ好友复制网址打印

您可能想查找下面的文章:

相关文章

  • 2017-05-28用c++实现x的y次幂的代码
  • 2017-05-28C语言使用stdlib.h库函数的二分查找和快速排序的实现代码
  • 2017-05-28C语言 结构体(Struct)详解及示例代码
  • 2017-05-28VC++获得当前进程运行目录的方法
  • 2017-05-28C++/Php/Python 语言执行shell命令的方法(推荐)
  • 2017-05-28浅析iterator与指针的区别
  • 2017-05-28C++实现十六进制字符串转换为十进制整数的方法
  • 2017-05-28C语言实现二叉树遍历的迭代算法
  • 2017-05-28C语言中查询进程信号是否被遮罩或搁置的简单方法
  • 2017-05-28算法之排序算法的算法思想和使用场景总结

文章分类

  • JavaScript
  • ASP.NET
  • PHP
  • 正则表达式
  • AJAX
  • JSP
  • ASP
  • Flex
  • XML
  • 编程技巧
  • Android
  • swift
  • C#教程
  • vb
  • vb.net
  • C语言
  • Java
  • Delphi
  • 易语言
  • vc/mfc
  • 嵌入式开发
  • 游戏开发
  • ios
  • 编程问答
  • 汇编语言
  • 微信小程序
  • 数据结构
  • OpenGL
  • 架构设计
  • qt
  • 微信公众号

最近更新的内容

    • C++自定义函数判断某年某月某日是这一年中第几天
    • C++多线程编程简单实例
    • C语言中使用快速排序算法对元素排序的实例详解
    • 解析C++中的虚拟函数及其静态类型和动态类型
    • C++ string 字符串查找匹配实例代码
    • C++如何实现广义表详解
    • C++ 将文件数据一次性加载进内存实例代码
    • C/C++中运算符的优先级、运算符的结合性详解
    • C语言 存储类详解及示例代码
    • C语言的Struct Hack笔记

关于我们 - 联系我们 - 免责声明 - 网站地图

©2020-2025 All Rights Reserved. linkedu.com 版权所有