题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6152

题意:判定一个无向图是否有三个点的团或者三个点的独立集。

解法:Ramsey theorem,n >= 6 直接输出 Bad 否则暴力。我是直接暴力,加个break优化就好了。

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn = 3e3+3;
bool w[maxn][maxn];
bool check(int n){
for(int i=1; i<=n; i++){
for(int j=i+1; j<=n; j++){
for(int k=j+1; k<=n; k++){
if(w[i][j]==w[i][k]&&w[i][k]==w[j][k]&&w[i][j]==w[j][k]){
return true;
}
}
}
}
return false;
}
struct FastIO
{
static const int S = 1310720;
int wpos;
char wbuf[S];
FastIO() : wpos(0) {}
inline int xchar()
{
static char buf[S];
static int len = 0, pos = 0;
if(pos == len)
pos = 0, len = fread(buf, 1, S, stdin);
if(pos == len)
exit(0);
return buf[pos ++];
}
inline unsigned long long xuint()
{
int c = xchar();
unsigned long long x = 0;
while(c <= 32)
c = xchar();
for(; '0' <= c && c <= '9'; c = xchar())
x = x * 10 + c - '0';
return x;
}
inline long long xint()
{
long long s = 1;
int c = xchar(), x = 0;
while(c <= 32)
c = xchar();
if(c == '-')
s = -1, c = xchar();
for(; '0' <= c && c <= '9'; c = xchar())
x = x * 10 + c - '0';
return x * s;
}
inline void xstring(char *s)
{
int c = xchar();
while(c <= 32)
c = xchar();
for(; c > 32; c = xchar())
* s++ = c;
*s = 0;
}
inline double xdouble()
{
bool sign = 0;
char ch = xchar();
double x = 0;
while(ch <= 32)
ch = xchar();
if(ch == '-')
sign = 1, ch = xchar();
for(; '0' <= ch && ch <= '9'; ch = xchar())
x = x * 10 + ch - '0';
if(ch == '.')
{
double tmp = 1;
ch = xchar();
for(; ch >= '0' && ch <= '9'; ch = xchar())
tmp /= 10.0, x += tmp * (ch - '0');
}
if(sign)
x = -x;
return x;
}
inline void wchar(int x)
{
if(wpos == S)
fwrite(wbuf, 1, S, stdout), wpos = 0;
wbuf[wpos ++] = x;
}
inline void wint(long long x)
{
if(x < 0)
wchar('-'), x = -x;
char s[24];
int n = 0;
while(x || !n)
s[n ++] = '0' + x % 10, x /= 10;
while(n--)
wchar(s[n]);
}
inline void wstring(const char *s)
{
while(*s)
wchar(*s++);
}
inline void wdouble(double x, int y = 6)
{
static long long mul[] = {1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000, 10000000000LL, 100000000000LL, 1000000000000LL, 10000000000000LL, 100000000000000LL, 1000000000000000LL, 10000000000000000LL, 100000000000000000LL};
if(x < -1e-12)
wchar('-'), x = -x;
x *= mul[y];
long long x1 = (long long) floorl(x);
if(x - floor(x) >= 0.5)
++x1;
long long x2 = x1 / mul[y], x3 = x1 - x2 * mul[y];
wint(x2);
if(y > 0)
{
wchar('.');
for(size_t i = 1; i < y && x3 * mul[i] < mul[y]; wchar('0'), ++i);
wint(x3);
}
}
~FastIO()
{
if(wpos)
fwrite(wbuf, 1, wpos, stdout), wpos = 0;
}
} io; int main()
{
int T,n,m;
T = io.xint();
while(T--)
{
n = io.xint();
for(int i=1; i<n; i++){
for(int j=i+1; j<=n; j++){
m = io.xint();
if(m == 1) w[i][j]=w[j][i]=false;
else w[i][j]=w[j][i]=true;
}
}
if(check(n)){
puts("Bad Team!");
}
else{
puts("Great Team!");
}
}
return 0;
}

2017中国大学生程序设计竞赛 - 网络选拔赛 HDU 6152 Friend-Graph 暴暴暴暴力的更多相关文章

  1. 2017中国大学生程序设计竞赛 - 网络选拔赛 HDU 6152 Friend-Graph(暴力搜索)

    题目传送:http://acm.hdu.edu.cn/showproblem.php?pid=6152 Problem Description It is well known that small ...

  2. 2017中国大学生程序设计竞赛 - 网络选拔赛 HDU 6155 Subsequence Count 矩阵快速幂

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6155 题意: 题解来自:http://www.cnblogs.com/iRedBean/p/73982 ...

  3. 2017中国大学生程序设计竞赛 - 网络选拔赛 HDU 6150 Vertex Cover 二分图,构造

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6150 题意:"最小点覆盖集"是个NP完全问题 有一个近似算法是说—每次选取度数最大 ...

  4. 2017中国大学生程序设计竞赛 - 网络选拔赛 HDU 6154 CaoHaha's staff 思维

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6154 题意:在笛卡尔坐标系下,画一个面积至少为  n 的简单多边形,每次只能画一条边或者一个格子的对角 ...

  5. 2017中国大学生程序设计竞赛 - 网络选拔赛 HDU 6153 A Secret KMP,思维

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6153 题意:给了串s和t,要求每个t的后缀在在s中的出现次数,然后每个次数乘上对应长度求和. 解法:关 ...

  6. 2017中国大学生程序设计竞赛 - 网络选拔赛 HDU 6156 数位DP

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6156 题意:如题. 解法:数位DP,暴力枚举进制之后,就转化成了求L,R区间的回文数的个数,这个直接做 ...

  7. 2017中国大学生程序设计竞赛 - 网络选拔赛 HDU 6154 CaoHaha's staff(几何找规律)

    Problem Description "You shall not pass!"After shouted out that,the Force Staff appered in ...

  8. 【2017中国大学生程序设计竞赛 - 网络选拔赛 && hdu 6154】CaoHaha's staff

    [链接]点击打开链接 [题意] 给你一个面积,让你求围成这个面积最少需要几条边,其中边的连线只能是在坐标轴上边长为1的的线或者是两个边长为1 的线的对角线. [题解] 找规律题 考虑s[i]表示i条边 ...

  9. 【2017中国大学生程序设计竞赛 - 网络选拔赛 hdu 6150】Vertex Cover

    [链接]点击打开链接 [题意] 有人写了一个最小点覆盖的贪心算法,然后,让你去hack它. 并且,要求这个算法得到的错误答案,是正确答案的三倍. 让你任意输出hack数据,点数<=500 [题解 ...

随机推荐

  1. 【poj2104】K-th Number 主席树

    题目描述 You are working for Macrohard company in data structures department. After failing your previou ...

  2. JS变量对象详解

    JS变量对象详解 开年之后工作热情一直不是很高,这几天一直处于消极怠工状态.早上不想起床,起床了不想上班.明明放假之前工作热情还一直很高,一直心心念念的想把小程序项目怼出来,结果休假回来之后画风完全不 ...

  3. MySQL基础原创笔记(一)

    对表的增删改操作: 创建表: create table student (          id  int  primary key  auto_increment,          name   ...

  4. bzoj2724: [Violet 6]蒲公英(离散化+分块)

    我好弱啊..这题调了2天QwQ 题目大意:给定一个长度为n(n<=40000)的序列,m(m<=50000)次询问l~r之间出现次数最多的数.(区间众数) 这题如果用主席树就可以不用处理一 ...

  5. ubuntu14.04安装GTX 1080 ti遇到黑屏问题

    实验室给我配置了一个1080ti的卡,那个激动,windows下1000+的FPS,跑分40W,无敌,言归正传,ubuntu14.04下配nvidia 1080的驱动还是出现了很多问题,差点就要重装系 ...

  6. Codeforces Round #402 (Div. 2) A B C sort D二分 (水)

    A. Pupils Redistribution time limit per test 1 second memory limit per test 256 megabytes input stan ...

  7. [rsync]rsync设定及错误处理

    server端设置      修改/etc/default/rsync RSYNC_ENABLE=true RSYNC_OPTS='--address=10.192.0.5' RSYNC_NICE=' ...

  8. JavaScript实现35选7并记录历史状态

    aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAL4AAABQCAYAAACnOs9vAAAJy0lEQVR4nO2dbWwUxxnH/2c5SElQSl ...

  9. Java集合(3)一 红黑树、TreeMap与TreeSet(上)

    目录 Java集合(1)一 集合框架 Java集合(2)一 ArrayList 与 LinkList Java集合(3)一 红黑树.TreeMap与TreeSet(上) Java集合(4)一 红黑树. ...

  10. SpringMVC中 Session的使用情况

    在SpringMVC中,使用Session可以用通过两种方式 1.servlet-api 即HttpSession session.setAttritute(),session.getAttribut ...