Problem C
来源:互联网 发布:视频录像软件 编辑:程序博客网 时间:2024/05/17 01:21
最大独立集
#include <iostream>
#include <cstdio>
#include <queue>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <algorithm>
//#include "myAlgorithm.h"
#define MAX 10005
#define OFFENCE (1e9 + 5)
#define INF (1e8 + 5)
#define eps 1e-9
#define Rep(s, e) for( int i = s; i <= e; i++)
#define Cep(e, s) for( int j = e; j >= s; j --)
#define PI acos(-1.0)
//#pragma comment(linker, "/STACK:36777216")
using namespace std;
int n;
int match[MAX],v[MAX];
vector<vector<int> >adj;
bool find(int node){
int len = adj[node].size(), pos;
Rep(0, len - 1){
pos = adj[node][i];
if(!v[pos]){
v[pos] = 1;
int pre = match[pos];
if(pre == -1 || find(pre)){
match[pos] = node;
//match[node] = pos;
return true;
}
}
}
return false;
}
int main() {
while(cin>>n){
adj.assign(n + 1, vector<int>() );
memset(match, -1, sizeof(match));
int c, a, s;
Rep(0, n - 1){
scanf("%d: (%d)", &s, &c);
//cout<<c<<endl;
for(int j = 0; j < c;j++){
scanf("%d", &a);
adj[s].push_back(a);
//cout<<a<<endl;
}
}///end make adj;
int ans = 0;
for(int i = 0; i < n; i++){
if(find(i))ans++;
memset(v, 0, sizeof(v));
}
//cout<<ans<<endl;
cout<<n - ans/2<<endl;
}
return 0;
}
/**
*/
- Problem C
- Problem C
- Problem C
- Problem C
- Problem C
- Problem C
- Problem c
- Problem C
- Problem C
- Problem C
- Problem C
- Problem C
- Problem-C
- Problem C
- Problem C
- Problem C
- Problem-C
- Problem C
- CSS浮动,你不知道的事(转载)
- Linux基本概念、命令总结
- How to Install mcrypt for php on Mac OSX Lion 10.8 & 10.7 Development Server
- wince下USB总线驱动分析
- nefu 674HELP(bfs)
- Problem C
- USB驱动程序的加载(二)
- java_基本数据类型的包装类
- 比较字符串大小strcmp
- USB驱动程序的加载(一)
- C++_运算符重载
- SQL Server 知识梳理六 存储过程的使用
- WinCE系统 USB Serial实现
- Problem D