hdu----(3118)Arbiter(构造二分图)
Arbiter
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)
Total Submission(s): 800 Accepted Submission(s): 410
is a kind of starship in the StarCraft science-fiction series. The
Arbiter-class starship is a Protoss warship specializing in providing
psychic support. Arbiters were crewed exclusively by Judicators; unlike
other warships that were manned predominantly by Templar. The Judicator
used the Arbiter as a base to provide support using space-time
manipulation.
Arbiters could weaken space-time, tearing rifts in the
fabric of space-time, creating a vortex linking another location to the
Arbiter’s location. This could be used to move personnel over long
distances between stars.
In the meantime of widely used Arbiter to
transfer, KMXS, the captain of one Arbiter, was warning that some person
had got a serious mental disorder after the trip on his Arbiter. By
using mice as model animals, he found the sake, it’s because of
chirality!
Every person has chirality, either left-handed or
right-handed. Actually all the persons must live with the food which has
the same chirality. When one person took Arbiter from one star to
another one, his chirality will be changed (from left-handed to
right-handed or from right-handed to left-handed). If a person took a
long trip and finally got back to his own star, however, his chirality
might be changed to the opposite state other than his original, which
would cause fatal mental disorder, or even death.
KMXS has the
channels map among the starts and he need to prohibit minimum number of
channels from traveling so that wherever a person starts his traveling
from when he gets his original star he’ll be safe. KMXS turns to your
help.
The
first line of each case consists of two integers N and M, indicating
the number of stars and the number of channels. Each of the next M lines
indicates one channel (u, v) which means there is a bidirectional
channel between star u and star v (u is not equal to v).
one integer on a single line for each case, indicating the minimum
number of channels KMXS must prohibit to avoid mental disorder.
Constraints
0 < T <= 10
0 <= N <= 15 0 <= M <= 300
0 <= u, v < N and there may be more than one channel between two stars.
3 3
0 1
1 2
2 0
Arbiter
Input
Output
Constraints
Sample Input
Sample Output
#include<cstring>
#include<cstdio>
const int maxn=;
int aa[maxn],bb[maxn];
int n,m;
int main(){
int test;
//freopen("test.in","r",stdin);
scanf("%d",&test);
while(test--){
scanf("%d%d",&n,&m);
for(int i=;i<m;i++){
scanf("%d%d",aa+i,bb+i);
}
int ans=m+;
for(int i=;i<(<<n);i++) //2^n种情况,对于每一个星球都可以两种情况要么为左,要么为右
{
int cnt=;
for(int j=;j<m;j++){
if(((i>>aa[j])%)==((i>>bb[j])%)) //属于同一个世界,说明呵呵存在奇数环
cnt++;
}
if(ans>cnt)ans=cnt;
}
printf("%d\n",ans);
}
return ;
}
hdu----(3118)Arbiter(构造二分图)的更多相关文章
- HDU 3118 Arbiter 判定奇圈
题目来源:pid=3118">HDU 3118 Arbiter 题意:翻译过来就是不能有奇圈 每走一步状态会变化 当他回到起点时假设和原来的状态不一样 可能会死 求至少去掉多少条边能够 ...
- hdu 3118 Arbiter
http://acm.hdu.edu.cn/showproblem.php?pid=3118 题意:删除最少的边使图没有奇环 二分图的定义:如果顶点能分为两个互不相交的子集,则图为二分图 二分 ...
- 2017中国大学生程序设计竞赛 - 网络选拔赛 HDU 6150 Vertex Cover 二分图,构造
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6150 题意:"最小点覆盖集"是个NP完全问题 有一个近似算法是说—每次选取度数最大 ...
- hdu 5727 Necklace dfs+二分图匹配
Necklace/center> 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5727 Description SJX has 2*N mag ...
- hdu 3118(二进制枚举)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3118 思路:题目要求是去掉最少的边使得图中不存在路径长度为奇数的环,这个问题等价于在图中去掉若干条边, ...
- HDU 1083 网络流之二分图匹配
http://acm.hdu.edu.cn/showproblem.php?pid=1083 二分图匹配用得很多 这道题只需要简化的二分匹配 #include<iostream> #inc ...
- hdu 5535 Cake 构造+记忆化搜索
链接:http://acm.hdu.edu.cn/showproblem.php?pid=5355 题意:给定n与m,其中1<= n <= 1e5,2 <= m <= 10;问 ...
- hdu 1151 Air Raid(二分图最小路径覆盖)
http://acm.hdu.edu.cn/showproblem.php?pid=1151 Air Raid Time Limit: 1000MS Memory Limit: 10000K To ...
- HDU 1150 Machine Schedule (二分图最小点覆盖)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1150 有两个机器a和b,分别有n个模式和m个模式.下面有k个任务,每个任务需要a的一个模式或者b的一个 ...
随机推荐
- CodeForces 552C Vanya and Scales
Vanya and Scales Time Limit:1000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u S ...
- MSChart BarChart
不让合并0-5 chart1.ChartAreas[].AxisX.LabelStyle.Interval = ; 效果
- 卡尔曼滤波—Simple Kalman Filter for 2D tracking with OpenCV
之前有关卡尔曼滤波的例子都比较简单,只能用于简单的理解卡尔曼滤波的基本步骤.现在让我们来看看卡尔曼滤波在实际中到底能做些什么吧.这里有一个使用卡尔曼滤波在窗口内跟踪鼠标移动的例子,原作者主页:http ...
- 纯CSS写三角形-border法
(1)有边框的三角形 我们来写下带边框的三角形. 如果是一个正方形,我们写边时,会用到border,但我们这里讨论的三角形本身就是border,不可能再给border添加border属性,所以我们需要 ...
- HDU 5813 Elegant Construction(优雅建造)
HDU 5813 Elegant Construction(优雅建造) Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/65 ...
- Codeforces Round #377 (Div. 2) D. Exams 二分
D. Exams time limit per test 1 second memory limit per test 256 megabytes input standard input outpu ...
- Perl5中19个最重要的文件系统工具
在写脚本处理文件系统时,经常需要加载很多模块.其中好多有用函数分散在各种不同的模块中.它们有些是Perl的内置函数,有些是在同Perl一起发行的标准模块中,另外一些是通过CPAN安装的. 下面来看15 ...
- bootstrap-datepicker 日期格式设置
[参考文档]http://bootstrap-datepicker.readthedocs.org/en/latest/ datepicker插件默认是时间格式为mm/dd/yyyy,如何更改时间的格 ...
- Redis核心知识之—— 时延问题分析及应对、性能问题和解决方法【★★★★★】
参考网址: Redis时延问题分析及应对:http://www.cnblogs.com/me115/p/5032177.html Redis常见的性能问题和解决方法:http://www.search ...
- Python学习(19)正则表达式
目录 Python 正则表达式 re.match 函数 re.search 方法 re.match 函数与 re.search 方法区别 检索和替换 正则表达式修饰符 - 可选标志 正则表达式模式 正 ...