标签:
/* Author: JDD PROG: bzoj1191 超级英雄 DATE: 2015.9.24 */ #include <cstdio> #include <cstring> #define REP(i, s, n) for(int i = s; i <= n; i ++) #define REP_(i, s, n) for(int i = n; i >= s; i --) #define MAX_N 1005 using namespace std; int n, m; int link[MAX_N][MAX_N], G[MAX_N]; bool used[MAX_N]; void init() { scanf("%d%d", &n, &m); memset(link, 0, sizeof(link)); memset(G, 0, sizeof(G)); REP(i, 1, m){ int x, y; scanf("%d%d", &x, &y), x ++, y ++; link[i][x] = 1; link[i][y] = 1; } } bool find(int x) { REP(j, 1, n){ if (link[x][j] == true && used[j] == false){ used[j]=1; if (G[j] == 0 || find(G[j])){ G[j] = x; return true; } } } return false; } void doit() { int ans = 0; REP(i, 1, m){ memset(used, 0, sizeof(used)); if(find(i)) ans ++; else break; } printf("%d\n", ans); } int main() { init(); doit(); return 0; }
标签:
原文地址:http://www.cnblogs.com/ALXPCUN/p/4836324.html