Arbiter

Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)
Total Submission(s): 800    Accepted Submission(s): 410

Problem Description
Arbiter
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.
 
Input
The first line of input consists of an integer T, indicating the number of test cases.
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).
 
Output
Output
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.

 
Sample Input
1
3 3
0 1
1 2
2 0
 
Sample Output
1
 
Source
 
这道题的意思:

Arbiter

     “仲裁者”是《星际争霸》科幻系列中的一种太空船。仲裁者级太空船是神族的战船,专门提供精神力支援。不像其他战船的人员主要是战士阶级,仲裁者所承载的都是统治阶级。统治者以仲裁者为基地,用时空操控来提供支援。
       仲裁者可以克服时空限制,撕裂时空,产生裂缝,制造涡洞,把另一个空间连接到仲裁者所在空间,可以用来运送人员,跨越长途星际。
       正当仲裁者广泛用于运输的时候,一艘仲裁者的船长 KMXS 发出警告,有些人员在他的船上完成旅程之后,得到严重的精神错乱。他用小白鼠做动物实验,找到了原因,是生物化学中的“手性”!
       每个人 都有手性,是左手性或者右手性。事实上,所有人的生存都必须依靠相同手性的食物。一个人乘坐仲裁者从一个星球到另一个星球的时候,他的手性会改变,(从左 手性变成右手性,或者从右手性变成左手性。)如果一个人经过长途旅行,最后回到自己的星球,可是他的手性却可能改变成跟原来的相反,那就会造成致命的精神 错乱,甚至死亡。 
       KMXS 拥有星球之间的航道图。他需要禁止通过航道的最少数目,以致无论一个人从哪里出发,当他回到自己的星球,会是安全的。KMXS请求你的帮助。

Input

  第一行输入有一个整数 T,表示测试用例的数目。
  每个用例的第一行有两个整数 N 和 M,表示星球的数目和航道的数目。随后的 M 行表示航道,每个 (u, v) 代表在星球 u 和星球 v 之间有一条双向的航道(u 不等于 v)。

Output

        每个测试用例的结果输出一行,用一个整数表示KMXS为了要避免人们精神错乱, 必须禁止的最少航道数目。

Constraints

    0 < T <= 10
    0 <= N <= 15 0 <= M <= 300
    0 <= u, v < N在两个星球之间可以有超过一条航道

Sample Input

    13 30 11 22 0

Sample Output

    1
很明显: 这个意思是,可以从任意一个星球,到大另一个星球,但是每个星球都有手性.....
要我们求出,对于任何一个星球出发都不能通过奇数次传递回到该星球...也就是不能形成奇数环..
而我们知道,二分图的充要条件是: 至少存在两个顶点,每一个点的回路的长度都是偶数...
所以只需进行擦边,来构成二分图就可以了.,...
代码:

 #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(构造二分图)的更多相关文章

  1. HDU 3118 Arbiter 判定奇圈

    题目来源:pid=3118">HDU 3118 Arbiter 题意:翻译过来就是不能有奇圈 每走一步状态会变化 当他回到起点时假设和原来的状态不一样 可能会死 求至少去掉多少条边能够 ...

  2. hdu 3118 Arbiter

    http://acm.hdu.edu.cn/showproblem.php?pid=3118   题意:删除最少的边使图没有奇环   二分图的定义:如果顶点能分为两个互不相交的子集,则图为二分图 二分 ...

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

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

  4. hdu 5727 Necklace dfs+二分图匹配

    Necklace/center> 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5727 Description SJX has 2*N mag ...

  5. hdu 3118(二进制枚举)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3118 思路:题目要求是去掉最少的边使得图中不存在路径长度为奇数的环,这个问题等价于在图中去掉若干条边, ...

  6. HDU 1083 网络流之二分图匹配

    http://acm.hdu.edu.cn/showproblem.php?pid=1083 二分图匹配用得很多 这道题只需要简化的二分匹配 #include<iostream> #inc ...

  7. hdu 5535 Cake 构造+记忆化搜索

    链接:http://acm.hdu.edu.cn/showproblem.php?pid=5355 题意:给定n与m,其中1<= n <= 1e5,2 <= m <= 10;问 ...

  8. hdu 1151 Air Raid(二分图最小路径覆盖)

    http://acm.hdu.edu.cn/showproblem.php?pid=1151 Air Raid Time Limit: 1000MS   Memory Limit: 10000K To ...

  9. HDU 1150 Machine Schedule (二分图最小点覆盖)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1150 有两个机器a和b,分别有n个模式和m个模式.下面有k个任务,每个任务需要a的一个模式或者b的一个 ...

随机推荐

  1. UVALive 6508 Permutation Graphs

    Permutation Graphs Time Limit:3000MS     Memory Limit:0KB     64bit IO Format:%lld & %llu Submit ...

  2. Cheatsheet: 2013 09.22 ~ 09.30

    Other Python basics summary Another article about big O notation Mobile Getting Started with PhoneGa ...

  3. [HDOJ5723]Abandoned country(最小生成树,期望)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5723 题意:求最小生成树,并且求这棵最小生成树上所有边走过次数的期望. 走过次数的期望=Σ边被走过次数 ...

  4. [HDOJ3709]Balanced Number(数位dp)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3709 题意:求区间[L,R]内每一个数中是否存在一位,使得左边的各位数*距离=右边的各位数*距离(自己 ...

  5. ubuntu下导入kali源

    Kali-Linux之前的渗透神器BackTrack是基于Ubuntu的,界面比较友好,字体渲染看起来也比较舒服(也可能是本人用惯了 Ubuntu的缘故).后来官方终止BackTrack,开发Kali ...

  6. [SAP ABAP开发技术总结]预定义(内置)数据类型

    声明:原创作品,转载时请注明文章来自SAP师太技术博客( 博/客/园www.cnblogs.com):www.cnblogs.com/jiangzhengjun,并以超链接形式标明文章原始出处,否则将 ...

  7. 7.mybatis一对多关联查询

    和第5节一对一查询类似,但是不同的是,一对一使用的是association,而一对多使用collection. 实例: 1个班级Class,对应1个老师Teacher,对应多个学生Student 1. ...

  8. Kazam: a perfect srceen recorder in Linux/Ubuntu

    Kazam provides a well designed and easy to use interface for capturing screencasts and screenshots. ...

  9. hdu 4223 Dynamic Programming?

    Dynamic Programming? Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Oth ...

  10. FLASH CC 2015 CANVAS (六)如何像FLASH那样实现场景(多canvas)

    注意 此系列贴 为个人边“开荒”边写,所以不保证就是最佳做法,也难免有错误! 正式教程会在后续开始更新. swf 项目中,我们可以很容易在一个fla文档里创建多场景.也可以通过多个fla文件发布多个s ...