2017中国大学生程序设计竞赛 - 网络选拔赛 HDU 6152 Friend-Graph(暴力搜索)
题目传送:http://acm.hdu.edu.cn/showproblem.php?pid=6152
In a team with n members,if there are three or more members are not friends with each other or there are three or more members who are friends with each other. The team meeting the above conditions can be called a bad team.Otherwise,the team is a good team.
A company is going to make an assessment of each team in this company. We have known the team with n members and all the friend relationship among these n individuals. Please judge whether it is a good team.
The first line od each case should contain one integers n, representing the number of people of the team.(n≤3000)
Then there are n-1 rows. The ith row should contain n-i numbers, in which number aij represents the relationship between member i and member j+i. 0 means these two individuals are not friends. 1 means these two individuals are friends.
题解:暴搜可以过,因为时间给的多。
然后保存的数组类型不是int是bool,要不然会MLE。
其实也可以发现当点数大于等于6的时候,都是bad team了。
#include <iostream>
#include<bits/stdc++.h>
using namespace std; bool a[][];//评论提醒只需a[7][7]即可
int t,n; bool work()
{
for(int i=;i<=n;i++)
{
for(int j=i+;j<=n;j++)
if(a[i][j]==)
{
for(int k=j+;k<=n;k++)
if (a[j][k]== && a[k][i]==) return ;
} else
{
for(int k=j+;k<=n;k++)
if(a[j][k]== && a[k][i]==) return ;
}
}
return ;
} int main()
{
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
for(int i=;i<=n;i++)
{
for(int j=;j<=n-i;j++)
{
int x;
scanf("%d",&x);
a[i][i+j]=x;
a[i+j][i]=x;
}
}
if (n>) {printf("Bad Team!\n"); continue;}
if(work()) printf("Great Team!\n");
else printf("Bad Team!\n");
}
return ;
}
2017中国大学生程序设计竞赛 - 网络选拔赛 HDU 6152 Friend-Graph(暴力搜索)的更多相关文章
- 2017中国大学生程序设计竞赛 - 网络选拔赛 HDU 6152 Friend-Graph 暴暴暴暴力
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6152 题意:判定一个无向图是否有三个点的团或者三个点的独立集. 解法:Ramsey theorem,n ...
- 2017中国大学生程序设计竞赛 - 网络选拔赛 HDU 6155 Subsequence Count 矩阵快速幂
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6155 题意: 题解来自:http://www.cnblogs.com/iRedBean/p/73982 ...
- 2017中国大学生程序设计竞赛 - 网络选拔赛 HDU 6150 Vertex Cover 二分图,构造
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6150 题意:"最小点覆盖集"是个NP完全问题 有一个近似算法是说—每次选取度数最大 ...
- 2017中国大学生程序设计竞赛 - 网络选拔赛 HDU 6154 CaoHaha's staff 思维
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6154 题意:在笛卡尔坐标系下,画一个面积至少为 n 的简单多边形,每次只能画一条边或者一个格子的对角 ...
- 2017中国大学生程序设计竞赛 - 网络选拔赛 HDU 6153 A Secret KMP,思维
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6153 题意:给了串s和t,要求每个t的后缀在在s中的出现次数,然后每个次数乘上对应长度求和. 解法:关 ...
- 2017中国大学生程序设计竞赛 - 网络选拔赛 HDU 6156 数位DP
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6156 题意:如题. 解法:数位DP,暴力枚举进制之后,就转化成了求L,R区间的回文数的个数,这个直接做 ...
- 2017中国大学生程序设计竞赛 - 网络选拔赛 HDU 6154 CaoHaha's staff(几何找规律)
Problem Description "You shall not pass!"After shouted out that,the Force Staff appered in ...
- 【2017中国大学生程序设计竞赛 - 网络选拔赛 && hdu 6154】CaoHaha's staff
[链接]点击打开链接 [题意] 给你一个面积,让你求围成这个面积最少需要几条边,其中边的连线只能是在坐标轴上边长为1的的线或者是两个边长为1 的线的对角线. [题解] 找规律题 考虑s[i]表示i条边 ...
- 【2017中国大学生程序设计竞赛 - 网络选拔赛 hdu 6150】Vertex Cover
[链接]点击打开链接 [题意] 有人写了一个最小点覆盖的贪心算法,然后,让你去hack它. 并且,要求这个算法得到的错误答案,是正确答案的三倍. 让你任意输出hack数据,点数<=500 [题解 ...
随机推荐
- HomeBrew的安装和简单使用
homebrew 官网 https://brew.sh/ 转自:http://blog.csdn.NET/maojudong/article/details/7918291 1. 前言 作为Linu ...
- oracle 12c新特性 FETCH FIRST、WITH TIES 关键字详解
几乎都是官方文档上的内容. [ OFFSET offset { ROW | ROWS} ] [ FETCH { FIRST | NEXT }[ { rowcount | percent PER ...
- CompareTo 基于的排序算法
CompareTo 基于的排序算法(高级排序) 这个是今天学习MapReduce时发现的,自定义类后实现了WritableComparable<>接口后实现了接口中的compareTo方法 ...
- Mysql for Linux安装配置之——二进制安装
1.准备及安装1)查看OS版本 # cat /etc/redhat-release 2)创建mysql组及用户 # groupadd mysql # cat /etc/group|grep m ...
- php-fpm占用cpu和内存过高100% 解决办法
参考网站: https://www.fujieace.com/php/php-fpm.html https://www.fujieace.com/php/pm-max_children-2.html ...
- linux jdk install and tomcat install
1● linux安装jdk1.8 Download jdk1.8 export JAVA_HOME=/usr/java/jdk1.8.0_181 export JRE_HOME=${JAVA_ ...
- vector list map set等容器某些函数的使用区别
map, set, vector erase的正确使用方法 一.erase 的用法区别 STL中的容器按存储方式分为两类,一类是按以数组形式存储的容器(如:vector .deque); 另一类是以不 ...
- 基于 Dropbear & Zlib 搭建轻量级的ssh server
[目的] 移植dropbear & zlib 在AM335X开发板上搭建轻量级的ssh server [环境] 1. Ubuntu 16.04发行版 2. MC183平台 3. 交叉编译 ...
- WPF技术实现控件截图
1.http://www.cnblogs.com/TianFang/archive/2012/10/07/2714140.html 2.http://www.silverlightchina.net/ ...
- HTML编辑笔记4
1.CSS(层叠样式表) 2.CSS语法 选择器{ 属性名1:属性值1: 属性名2:属性值2: } 3.引用CSS的三种方式 第一种:行内样式 例:<a style="color:re ...