HDU - 6152 Friend-Graph(暴力)
题意:给定n个人的关系,若存在三个及以上的人两两友好或两两不友好,则"Bad Team!",否则"Great Team!"。
分析:3000*3000内存10000+,因此存关系要用bool数组,否则mle。
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cctype>
#include<cmath>
#include<iostream>
#include<sstream>
#include<iterator>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<deque>
#include<queue>
#include<list>
#define Min(a, b) ((a < b) ? a : b)
#define Max(a, b) ((a < b) ? b : a)
const double eps = 1e-12;
inline int dcmp(double a, double b)
{
if(fabs(a - b) < eps) return 0;
return a > b ? 1 : -1;
}
typedef long long LL;
typedef unsigned long long ULL;
const int INT_INF = 0x3f3f3f3f;
const int INT_M_INF = 0x7f7f7f7f;
const LL LL_INF = 0x3f3f3f3f3f3f3f3f;
const LL LL_M_INF = 0x7f7f7f7f7f7f7f7f;
const int dr[] = {0, 0, -1, 1, -1, -1, 1, 1};
const int dc[] = {-1, 1, 0, 0, -1, 1, -1, 1};
const int MOD = 1e9 + 7;
const double pi = acos(-1.0);
const int MAXN = 3000 + 10;
const int MAXT = 3025 + 10;
using namespace std;
bool pic[MAXN][MAXN];
int main(){
int T;
scanf("%d", &T);
while(T--){
memset(pic, 0, sizeof pic);
int n;
scanf("%d", &n);
int x;
for(int i = 1; i <= n; ++i){
for(int j = i + 1; j <= n; ++j){
scanf("%d", &x);
if(x) pic[j][i] = pic[i][j] = true;
else pic[j][i] = pic[i][j] = false;
}
}
bool ok = true;
for(int i = 1; i <= n; ++i){
for(int j = i + 1; j <= n; ++j){
for(int k = j + 1; k <= n; ++k){
if((pic[i][j] && pic[i][k] && pic[j][k]) || (!pic[i][j] && !pic[i][k] && !pic[j][k])){
ok = false;
break;
}
}
if(!ok) break;
}
if(!ok) break;
}
if(ok) printf("Great Team!\n");
else printf("Bad Team!\n");
}
return 0;
}
HDU - 6152 Friend-Graph(暴力)的更多相关文章
- 2017中国大学生程序设计竞赛 - 网络选拔赛 HDU 6152 Friend-Graph(暴力搜索)
题目传送:http://acm.hdu.edu.cn/showproblem.php?pid=6152 Problem Description It is well known that small ...
- HDU 6321 Dynamic Graph Matching
HDU 6321 Dynamic Graph Matching (状压DP) Problem C. Dynamic Graph Matching Time Limit: 8000/4000 MS (J ...
- 2017中国大学生程序设计竞赛 - 网络选拔赛 HDU 6152 Friend-Graph 暴暴暴暴力
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6152 题意:判定一个无向图是否有三个点的团或者三个点的独立集. 解法:Ramsey theorem,n ...
- HDU 5631 Rikka with Graph 暴力 并查集
Rikka with Graph 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5631 Description As we know, Rikka ...
- HDU 5636 Shortest Path 暴力
Shortest Path 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5636 Description There is a path graph ...
- hdu 5461 Largest Point 暴力
Largest Point Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid= ...
- 图论(生成树):HDU 5631Rikka with Graph
Rikka with Graph Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) ...
- HDU 5876 Sparse Graph 【补图最短路 BFS】(2016 ACM/ICPC Asia Regional Dalian Online)
Sparse Graph Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)To ...
- HDU 6152 - Friend-Graph
Friend-Graph Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Tot ...
随机推荐
- android悬浮按钮(Floating action button)的两种实现方法
原文: http://www.jcodecraeer.com/a/anzhuokaifa/androidkaifa/2014/1028/1857.html 最近android中有很多新的设计规范被引入 ...
- PAT A 1020 Tree Traversals
给出一棵二叉树的后序遍历序列和中序遍历序列,求这棵二叉树的层序遍历序列 #include<iostream> #include<cstring> #include<que ...
- Fiddler抓包(基本使用方法、web+app端抓包、篡改数据、模拟低速)
1.HTTP代理原理图 http服务器代理:既是web服务器,又是web客户端 接口vs端口: 接口:包含地址和端口 端口:类似于USB接口 地址:127.0.0.1,端口默认:8888 ...
- MyEclipse JSP页面中文字符不能保存
问题: 就是写HTML+JSP代码时有些中文,保存时提示sava could not be completed. Reason: some characters cannot be mapped ...
- Batch批量替换hosts
hosts文件替换 工作需要,要修改很多计算机的hosts文件,采用bat批量完成 解决的问题: 1.pc工作在非管理员权限,右键管理员权限太麻烦,因此采用执行中申请管理员权限的方式 2.hosts和 ...
- A. Optimal Currency Exchange 兑换硬币,剩下的钱最少
A. Optimal Currency Exchange time limit per test 1.5 seconds memory limit per test 512 megabytes inp ...
- 随机序列[SHOI2016](找规律+线段树)
传送门 这道题的题意就是给你n个数让你在每个数之间插入+.-.*三种运算符中的一种,然后算出一个答案,再把答案加起来. 这题肯定是不能暴力的(题目都告诉你了由3n-1种结果).我们先从小的情况枚举找一 ...
- Numpy与List之间的转换
说明:在做NLP的时候,经常需要查看当前数组数据的维度,也就是data.shape,而List是没有这个属性的,因此需要先将其转换成Numpy,以下为两者户想转换的方法 List转Numpy:nump ...
- 关于Lab3中对于正则表达式的应用
在这里记录一下关于软件构造课程Lab3中关于正则表达式的应用. 在实验内容中,要求用正则表达式来匹配读入文件的内容,从而取得构建图需要的相关信息. 举个例子,读入的文件(GraphPoetTestFi ...
- emWin 模拟器环境搭建
转载http://www.nxpic.org/module/forum/thread-609329-1-1.html 这个模拟器工程在Segger官网下载:https://www.segger.com ...