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 ...
随机推荐
- Spark程序编译报错error: object apache is not a member of package org
Spark程序编译报错: [INFO] Compiling 2 source files to E:\Develop\IDEAWorkspace\spark\target\classes at 156 ...
- idea中scala语言自动补全变量的同时,也自动补全类型
IDE是IDEA,scala中,在new一个对象时,通过快捷键ctrl + Alt + V自动补全变量,但是我还想自动补全变量的类型,就像图中所示,在Specify type前面自动帮你打勾. 可以按 ...
- [转载]android 显示多选列表对话框setMultiChoiceItems
public class MultiChoiceItemsTest extends Activity implements OnClickListener { private String[] pro ...
- Vue -> 解决 vue-ueditor-wrap 不能显示的问题
- Qt编译Curl
1.下载Curl,下载地址:https://curl.haxx.se/download.html,windows下载.zip压缩包,解压到E盘. 2.在”开始菜单“—>”所有程序“->”Q ...
- 记一个 protobuf 的 jar 包冲突
尝试使用 spark 以 bulkload 的方式写 HBase 时,遇到一个问题,错误堆栈如下 19/02/02 09:00:43 ERROR Utils: Aborting task java.l ...
- 对Python中列表和数组的赋值,浅拷贝和深拷贝的实例讲解
引用:https://www.jb51.net/article/142775.htm 列表赋值: 1 2 3 4 5 6 7 >>> a = [1, 2, 3] >>&g ...
- Redis有序集合类型
命令 增加元素 ZADD score member [score member ...] > ZADD scoreboard 89 Tom 76 Peter 100 David (integer ...
- Eclipse之Cannot open Eclipse Marketplace
今天给eclipse安装插件的时候出现各种cannot connect to...的问题, 想打开eclipse marketplace来安装插件出现Cannot open Eclipse Marke ...
- 字典NSDictionary和NSMutableDictionary的使用
简介:字典是一种数据结构,字典里面的每一个元素,是一个key-value(键值对),key和value都是对象类型.同NSArray一样,里面的对象不用保持一致性. NSDictionary 1.字面 ...