思路:一哥们要去杀人,这些人之间呢有相互认识的,也有不认识的,如果杀了A,那么认识A的人就回得到消息然后有所防范,问最多能杀多杀人,这显然就是最大独立集。
/*****************************************
Author :Crazy_AC(JamesQi)
Time :2015
File Name :
*****************************************/
// #pragma comment(linker, "/STACK:1024000000,1024000000")
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <sstream>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <map>
#include <set>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>
using namespace std;
#define MEM(a,b) memset(a,b,sizeof a)
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int,int> ii;
const int inf = 1 << 30;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const int maxn = 1010;
bool vis[maxn];
int gg[maxn][maxn];
int link[maxn];
int n,m;
bool SearchP(int u){
for (int i = 1;i <= n;i++){
if (gg[u][i] && !vis[i]){
vis[i] = true;
if (link[i] == -1 || SearchP(link[i])){
link[i] = u;
// link[u] = i;
return true;
}
}
}
return false;
}
inline int Hungary(){
MEM(link, -1);
int ret = 0;
for (int i = 1;i <= n;i++){
// if (link[i] < 0){
MEM(vis, false);
if (SearchP(i)) ret++;
// }
}
return ret;
}
int main()
{
// freopen("in.txt","r",stdin);
// freopen("out.txt","w",stdout);
int T;
cin >> T;
int icase = 0;
while(T--){
cin >> n >> m;
int u,v;
MEM(gg, 0);
for (int i = 1;i <= m;i++){
cin >> u >> v;
gg[u][v] = gg[v][u] = 1;
}
// cout << Hungary() << endl;
cout << "Case " << ++icase << ": ";
cout << n - Hungary() / 2 << endl;
}
return 0;
}