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 ...
随机推荐
- 学习不一样的vue5:vuex(完结)
学习不一样的vue5:vuex(完结) 发表于 2017-09-10 | 分类于 web前端| | 阅读次数 4029 首先 首发博客: 我的博客 项目源码: 源码(喜欢请star) 项目预览 ...
- arduino#呼吸灯
; // 使用引脚号 void setup() { // nothing happens in setup } void loop() { // fade in from min to max in ...
- SRS源码——UDP
srs_app_server.cpp int SrsServer::listen() { int ret = ERROR_SUCCESS; if ((ret = listen_rtmp()) != ...
- Python 之并发编程之进程下(事件(Event())、队列(Queue)、生产者与消费者模型、JoinableQueue)
八:事件(Event()) # 阻塞事件: e = Event() 生成事件对象e e.wait() 动态给程序加阻塞,程序当中是否加阻塞完全取决于该对象中的is_set() [默认返回值 ...
- win7 X64 进程名称不一致,导致杀进程失效!
win7 x86, 或 win10 x64 环境下, x86的进程名称 ”aaa.exe“ 在win7 x64下面显示为 ”aaa.exe *32“
- 嵊州普及Day6T3
题意:n个点,对于q个询问,有t秒及一个矩形的范围.在此矩形内的数每秒加1,若等于c,则下一秒变为0. 思路:t可能很大,%c+1就可以了.然后一个一个加起来就可以了. 见代码: #include&l ...
- js中每隔一段时间执行一次
window.setInterval("flushs()",1000);
- .net设计模式
1.单例模式 public sealed class Singleton { static intance=null; static readonly object padlock=new objec ...
- Java中Comparator的使用
在某些特殊情况,我们需要对一个对象数组或集合依照对应的属性排序:此时,我们就可以用Comparator接口处理. 上代码 TestComparaTo 类 package com.test.interf ...
- 事件驱动的TCP协议Socket通信
事件驱动的TCP协议Socket通信 介绍 常规的Socket通信案例一般都是在某个线程中建立连接,然后用一个while(true)循环判断是或否有数据传输,但是这种方法有局限性. 1.收到消息在处理 ...