#include #include #include #include #include #include #include #include using namespace std; const int N = 510, M = N * N; // 链式前向星 int e[M], h[N], idx, w[M], ne[M]; void add(int a, int b, int c = 0) { e[idx] = b, ne[idx] = h[a], w[idx] = c, h[a] = idx++; } // 匈牙利算法模板 int match[N], st[N]; int dfs(int u) { for (int i = h[u]; ~i; i = ne[i]) { int v = e[i]; if (st[v]) continue; st[v] = 1; if (match[v] == -1 || dfs(match[v])) { match[v] = u; return 1; } } return 0; } int main() { #ifndef ONLINE_JUDGE freopen("POJ1466.in", "r", stdin); #endif int n; while (~scanf("%d", &n)) { memset(h, -1, sizeof h); idx = 0; for (int i = 0; i < n; i++) { int m, a, b; scanf("%d: (%d)", &a, &m); while (m--) { scanf("%d", &b); add(a, b); } } int res = 0; memset(match, -1, sizeof match); for (int i = 0; i < n; i++) { memset(st, 0, sizeof st); if (dfs(i)) res++; } printf("%d\n", n - res / 2); } return 0; }