Title: Find out who is not in love with each other.
Spit Groove: 500 points with the adjacency matrix of more than 4,000 MS, with the adjacency table 1000ms less than, so about 500 points should consider the adjacency table.
/************************************************author:D arktongcreated time:2016/7/31 20:12:30File Name: poj_1466.cpp*************************************************///#include <bits/stdc++.h>#include <cstring>#include<cstdio>#include<vector>using namespacestd;Const intMAXN = -+Ten; Vector<int>W[MAXN];intN, M;intLEFT[MAXN];BOOLUSED[MAXN];BOOLMatchintj) { for(intI=0; I<w[j].size (); ++i)if(!Used[w[j][i]]) { intv =W[j][i]; USED[V]=true; if(left[v]==-1||match (Left[v])) {Left[v]=J; return true; } } return false;}//returns the maximum number of matchesintHungary () {intres=0; Memset (left,-1,sizeof(left)); for(intI=0; i<m;++i) {memset (used,0,sizeof(used)); if(Match (i)) res++; } returnRes;}intMain () {intT, cas=1; while(SCANF ("%d", &n) = =1) {memset (W,0,sizeof(w)); M=N; for(intI=0; i<n;++i) {intu, t, V; scanf ("%d: (%d)", &u, &t); for(intj=0; j<t;++j) {scanf ("%d", &v); W[u].push_back (v); }} printf ("%d\n", (2*n-hungary ()) >>1); } return 0;}
poj_1466 Girls and Boys-Maximum independent set