设为首页 加入收藏

TOP

hdu3118Arbiter (利用二分图的定义,枚举每种状态)
2015-07-20 18:01:14 来源: 作者: 【 】 浏览:2
Tags:hdu3118Arbiter 利用 二分 定义 枚举 每种 状态

Arbiter

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


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题意:一个人从通道一个星球到另一个星球他的左手变右手,右手变左手,如果存在回到原来的星球他的左右手不是原来的状态的话,这是致命的,为了使这种情况不能发生,最少需要册除多少条边。 也就是可以理解成:删去最少的边,使图中不存在奇圈。二分图的定义:在无向图G中,至少有两个点且如果存在回路,那么回路必须为偶回路。这样才是二分图。所以根据定义可知:把n个点分成两部分,每一部分内的点集任意两点不相连。把相连的边就册除。这样的分法有2^n种。 最后找出册除边数最少的就是所要求的。
#include
   
    
#include
    
      #include
     
       #include
      
        using namespace std; int map[20][20],n; int deletEdg(int k) { int ans=0; for(int i=0;i
       
        

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇[算法浅析] 如何在O(1)的时间里删.. 下一篇POJ2001_Shortest Prefixes(字典..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: