/* Question: machine A has n (0 ~ N-1) mode. Machine B has m (0 ~ M-1) mode, there are K tasks to be done first. You can use the AI mode of machine A or the Bi mode of machine B to do tasks without sequence. Restart the tasks in order of mode change, start two machines in the Mode 0 ask at least the restart is required several times. In the mode where the minimum vertex of the Bipartite Graph overwrites A, X Set B. In the mode where the y set calculates the minimum vertex overwrite task by task creation edge. minimum number of restarts, that is to say, it should work in at least several modes (except for the 0 mode) as long as any vertex of the edge is selected, so the minimum vertex overwrites These vertices and captures all edges, set to complete all tasks. The mode is the pattern minimum point covered by the store = maximum matching of the Bipartite Graph */# include <stdio. h ># include <vector> using namespace STD; int n, m, K; vector <int> V [201]; int vis [201]; int match [201]; int DFS (int I) {for (Int J = 0; j <V [I]. size (); ++ J) {If (! Vis [V [I] [J] + N]) // + N indicates the adjustment number {vis [V [I] [J] + N] = 1; if (Match [V [I] [J] + N] =-1 | DFS (Match [V [I] [J] + N]) {match [V [I] [J] + N] = I; return 1 ;}}return 0 ;}int main () {int I, A, B, C; while (scanf ("% d", & N), n) {scanf ("% d", & M, & K); for (I = 0; I <= m + n; ++ I) V [I]. clear (); for (I = 1; I <= K; ++ I) {scanf ("% d", & A, & B, & C); If (B & C) V [B]. push_back (c); // you only need to point from X set to y set. When DFS () is completed, it is only from X to Y} A = 0; /// match part of memset (match,-1, sizeof (MATCH); for (I = 1; I <= N; I ++) {memset (VIS, 0, sizeof (VIS); If (DFS (I) A ++;} // printf ("% d \ n", );} return 0 ;}