2014
03-02

# Arbiter

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.

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).

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).

1
3 3
0 1
1 2
2 0

1

#include<cstdio>
#include<iostream>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
const int maxn = 300 + 5;
const int INF = 100000 + 5;

int from[maxn],to[maxn];
int col[20];

int main(){
int t;
scanf("%d",&t);
while(t--){
int n,m;
scanf("%d%d",&n,&m);
for(int i = 0;i < m;i++) scanf("%d%d",&from[i],&to[i]);
int ans = m;
for(int i = 0;i < (1 << n);i++){
int tem = i;
for(int j = 0;j < n;j++){
col[j] = tem%2;
tem /= 2;
}
int sum = 0;
for(int j = 0;j < m;j++){
int x = from[j];
int y = to[j];
if(col[x] == col[y]) sum++;
}
ans = min(ans,sum);
}
printf("%d\n",ans);
}
return 0;
}