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


【题意】


有一个队伍,如果队伍里有三个或三个以上的人互相认识 或者队伍里有三个或三个以上的人互相不认识,那么这个队伍为bad team, 否则为great team。

【题解】


参考上一篇文章的求3元环做法。

只不过在两张图上进行而已.

两个递归可以合在一起写的。

(不是朋友的话标记这条边为0,是朋友标记这条边为1)

在标记为0的图上做一遍,在标记为1的图上做一遍.

【错的次数】


0

【反思】


【代码】

#include <bits/stdc++.h>
using namespace std;
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define LL long long
#define rep1(i,a,b) for (int i = a;i <= b;i++)
#define rep2(i,a,b) for (int i = a;i >= b;i--)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ms(x,y) memset(x,y,sizeof x)
#define ri(x) scanf("%d",&x)
#define rl(x) scanf("%lld",&x)
#define rs(x) scanf("%s",x+1)
#define oi(x) printf("%d",x)
#define ol(x) printf("%lld",x)
#define oc putchar(' ')
#define os(x) printf(x)
#define all(x) x.begin(),x.end()
#define Open() freopen("F:\\rush.txt","r",stdin)
#define Close() ios::sync_with_stdio(0)
#define ll long long
using namespace std;
const int MAXN = 3e3+100;
bool ar[MAXN][MAXN];
bool v[MAXN][2];
int n; bool dfs(int i,int dad,bool f)
{
v[i][f]=true;
rep1(j,1,n){
if(j==i) continue;
if(ar[i][j]==f){
if(i!=dad&&j!=dad&&i!=j&&ar[j][dad]==f)
return true;
if(!v[j][f])
if(dfs(j,i,f)) return true;
}
}
return false;
} main()
{
int t;
ri(t);
while(t--){
ms(v,0);
ri(n);
rep1(i,1,n-1){
rep1(j,1,n-i){
int tem;
ri(tem);
ar[i][i+j]=ar[i+j][i]=tem;
}
}
bool f=1;
rep1(i,1,n){
if(!v[i][0]){
if(dfs(i,i,0)) f=0;
}
if(!v[i][1]){
if(dfs(i,i,1)) f=0;
}
if(!f) break;
}
if(f)
puts("Great Team!");
else
puts("Bad Team!");
}
return 0;
}

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

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

    /* HDU 6154 - CaoHaha's staff [ 构造,贪心 ] | 2017 中国大学生程序设计竞赛 - 网络选拔赛 题意: 整点图,每条线只能连每个方格的边或者对角线 问面积大于n的 ...

  2. HDU 6150 - Vertex Cover | 2017 中国大学生程序设计竞赛 - 网络选拔赛

    思路来自 ICPCCamp /* HDU 6150 - Vertex Cover [ 构造 ] | 2017 中国大学生程序设计竞赛 - 网络选拔赛 题意: 给了你一个贪心法找最小覆盖的算法,构造一组 ...

  3. HDU 6156 - Palindrome Function [ 数位DP ] | 2017 中国大学生程序设计竞赛 - 网络选拔赛

    普通的数位DP计算回文串个数 /* HDU 6156 - Palindrome Function [ 数位DP ] | 2017 中国大学生程序设计竞赛 - 网络选拔赛 2-36进制下回文串个数 */ ...

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

    题目代号:HDU 6154 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6154 CaoHaha's staff Time Limit: 2000/1 ...

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

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

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

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

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

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

  8. 2017中国大学生程序设计竞赛 - 网络选拔赛 1004 HDU 6153 A Secret (字符串处理 KMP)

    题目链接 Problem Description Today is the birthday of SF,so VS gives two strings S1,S2 to SF as a presen ...

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

    题目链接 Problem Description "You shall not pass!" After shouted out that,the Force Staff appe ...

  10. 2017中国大学生程序设计竞赛 - 网络选拔赛 1003 HDU 6152 Friend-Graph (模拟)

    题目链接 Problem Description It is well known that small groups are not conducive of the development of ...

随机推荐

  1. ajax中json格式数据如何朝后端发送数据

  2. pic16f877a的AD实验学习

    一.主函数 //采集AD值 #include <pic.h> #include "ad.h" #include "usart.h" __CONFIG ...

  3. [六省联考2017]分手是祝愿 题解(期望dp)

    题目描述 B 君在玩一个游戏,这个游戏由 n 个灯和 n 个开关组成,给定这 n 个灯的初始状态,下标为从 1 到 n 的正整数. 每个灯有两个状态亮和灭,我们用 1 来表示这个灯是亮的,用 0 表示 ...

  4. MySQL 5.7配置文件

    原文:http://www.voidcn.com/article/p-zrikccdi-hr.html # MySql5.7配置文件my.cnf设置[client]port = 3306socket ...

  5. 64、通过PickListValuesUtil,Schema查看下拉列表中的值

    public class PickListValuesUtil { public static Map<String,Object> getPicklistValues(String sO ...

  6. nginx logformat说明

    记录一下nginx logformat的相关说明 log_format格式变量:$remote_addr  #记录访问网站的客户端地址$remote_user  #远程客户端用户名$time_loca ...

  7. Codeforces 388C Fox and Card Game (贪心博弈)

    Codeforces Round #228 (Div. 1) 题目链接:C. Fox and Card Game Fox Ciel is playing a card game with her fr ...

  8. PAT甲级——A1153 DecodeRegistrationCardofPAT【25】

    A registration card number of PAT consists of 4 parts: the 1st letter represents the test level, nam ...

  9. linux下vnstat查看服务器带宽流量统计

      因为很多vps或者服务器都是限流量的,但是又很多服务商并没有提供详细的流量表,比如每天的流量表,所以肯定有人很想知道自己服务器到底跑了多少流量. vnstat就是一个很好用的服务器流量统计命令.我 ...

  10. 分布式-技术专区-Redis并发竞争key的解决方案详解

    Redis缓存的高性能有目共睹,应用的场景也是非常广泛,但是在高并发的场景下,也会出现问题:缓存击穿.缓存雪崩.缓存和数据一致性,以及今天要谈到的缓存并发竞争.这里的并发指的是多个redis的clie ...