Friend-Graph(暴力枚举)
来源:互联网 发布:历史股价数据 编辑:程序博客网 时间:2024/06/05 19:16
Friend-Graph
Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 3254 Accepted Submission(s): 523
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.
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. Thei 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.
The first line od each case should contain one integers n, representing the number of people of the team.(
Then there are n-1 rows. The
Output
Please output ”Great Team!” if this team is a good team, otherwise please output “Bad Team!”.
Sample Input
141 1 00 01
Sample Output
Great Team!
题意:
给你一组人,如果一组人有三个人互相有关系或者有三个人和任何一个人都没关系,这就是一个bad team!给你数据让你判断。】
思路:
暴力枚举
代码:
#include <iostream>#include <cstring>#include <stdio.h>#include <algorithm>using namespace std;bool mp[3010][3010];bool finded(int n){int i,j,k;for(i=1;i<=n;i++)for(j=i+1;j<=n;j++)for(k=j+1;k<=n;k++){if(mp[i][j]==mp[i][k]&&mp[i][k]==mp[j][k]&&mp[i][j]==mp[j][k]) return 1;}return 0;}int main(){ int i,j;int n,m;cin>>n;int q;while(n--){cin>>m;for(i=1;i<m;i++){for(j=i+1;j<=m;j++){cin>>q;if(q==1)mp[j][i]=mp[i][j]=0;else mp[j][i]=mp[i][j]=1; }}bool flag=finded(m);if(!flag)cout<<"Great Team!"<<endl;else cout<<"Bad Team!"<<endl;}return 0;}
阅读全文
0 0
- Friend-Graph(暴力枚举)
- Friend-Graph (暴力)
- HDU 6152 Friend-Graph(暴力)
- HDU-6152 Friend-Graph (思维+暴力)
- HDU_6152 Friend-Graph 【暴力】
- Friend-Graph---枚举
- Hdu 6152 Friend-Graph【暴力】
- HDU 6152 Friend-Graph(拉姆齐定理+暴力)
- HDU Friend-Graph【暴力】【卡内存】【水题】
- HDUoj 6152 Friend-Graph ( 数学/暴力
- hdu6152 Friend-Graph (2017 ccpc 网络赛 (暴力 + 一个神奇的定理)
- 2017CCPC网络赛 Friend-Graph(暴力、拉姆齐(Ramsey)定理)
- 2017ccps网络赛 1003 Friend-Graph(暴力)HDU 6152
- Friend-Graph(数学,思维)
- HDU Friend-Graph(离散数学)
- Friend-Graph(HDU 3152)
- CCPC2017网络赛1003Friend-Graph——暴力
- Friend-Graph
- 学习shell脚本之前的基础知识
- C++学习笔记系列三
- linux中普通用户修改密码出现(passwd:Authentication token manipulation error)
- HDU1087 Super Jumping! Jumping! Jumping!
- linux开机启动自动执行某个脚本
- Friend-Graph(暴力枚举)
- 用 Python 实现每秒处理 120 万次 HTTP 请求
- RxJava基础使用
- mybatis配置
- 算法学习之枚举--熄灯问题POJ1222EXTENDED LIGHTS OUT
- ConcurrentModificationException异常及解决方案
- 极角排序学习
- linux常用命令
- linux基础知识回顾