#include #include using namespace std; bool augment(vector> &bigraph, vector &matching, vector &visited, int current_node){ for(int v: bigraph[current_node]){ if (not visited[v]){ visited[v]= true; if (matching[v]==-1 || augment(bigraph,matching,visited,matching[v])){ matching[v] = current_node; return true; } } } return false; } int min_bipartite_vertex_cover(int V, vector> bigraph) { vector matching(V,-1); for(int u = 0; u < V; u++){ vector visited(V,false); augment(bigraph, matching, visited,u); } int size_min_cover = 0; for(int m: matching){ if (m != -1) { size_min_cover+=1; } } return size_min_cover/2; } int main() { // input to bigraph int N,M; cin >> N >> M; int V = N+M; vector> bigraph(V); for(int i = 0; i < N; i++){ int ki; cin >> ki; for(int j = 0; j < ki; j++){ int cj; cin >> cj; bigraph[N-1+cj].push_back(i); bigraph[i].push_back(N-1+cj); } } cout << min_bipartite_vertex_cover(V, bigraph); return 0; }