This question is very simple. At first glance, we can see that it is the biggest matching question of binary. As long as it is used to contact the template.
Code:
# Include <cstdio> # include <cstring> # include <algorithm> using namespace STD; const int Ln = 110; const int Rn = 310; int ln, RN; int G [Ln] [Rn], CX [Ln], CY [Rn]; // store the matching bool used [Rn]; bool DFS (int u) {for (INT v = 1; v <= rn; ++ v) if (G [u] [v] &! Used [v]) {used [v] = true; If (CY [v] =-1 | DFS (CY [v]) {CY [v] = u; CX [u] = V; return 1 ;}} return 0 ;}int match () {int res = 0; memset (CX, -1, sizeof (CX); memset (CY,-1, sizeof (CY); For (INT u = 1; U <= ln; ++ U) {memset (used, 0, sizeof (used); If (DFS (u) RES ++;} return res ;}int main () {int T; scanf ("% d", & T); While (t --) {memset (G, 0, sizeof (g); scanf ("% d ", & ln, & RN); For (INT I = 1; I <= ln; ++ I) {int num; scanf ("% d", & num ); while (Num --) {int V; scanf ("% d", & V); G [I] [v] = 1 ;}} if (MATCH () = ln) printf ("Yes \ n"); else printf ("NO \ n ");}}