#include #include #include #include #include #include #include #include #include #include using namespace std; #define INF 0x2fffffff #define LL long long #define MAX(a,b) ((a)>(b))?(a):(b) #define MIN(a,b) ((a)<(b))?(a):(b) int n,m; int s = 0; int e; int cx[205]; int cy[205]; vector vec[205]; int vis[205]; int path(int u){ int si = vec[u].size(); for(int i = 0;i < si;i++){ int v = vec[u][i]; if(!vis[v]){ vis[v] = 1; if((cy[v] == -1|| path(cy[v]))){ cx[u] = v; cy[v] = u; return 1; } } } return 0; } int max_match(){ memset(cx,-1,sizeof(cx)); memset(cy,-1,sizeof(cy)); memset(vis,0,sizeof(vis)); int ans = 0; for(int i = 1;i <= n;i++){ if(cx[i] == -1){ memset(vis,0,sizeof(vis)); ans += path(i); } } return ans; } int main(){ while(cin >> n >> m){ for(int i = 0;i < n;i++){ vec[i].clear(); } for(int i = 1;i <= n;i++){ int g; scanf(%d,&g); for(int j = 0;j < g;j++){ int x; scanf(%d,&x); vec[i].push_back(x); } } cout << max_match() << endl; } return 0; }
POJ 2528 Mayor's poste
C++拾遺--類成員指針 C++拾遺--類成員指針 前言
[cpp] /* * 程序的
[LeetCode]165.Compare Version
全排列打印 全排列的要求: 輸入:字符串"a