Give you a two-point chart to ask you the biggest regiment for how big
Jie Yi: Pressure DP
2:2 maximum matching of the figure
Maximal group of binary graphs = maximum independent set of complement graphs
Binary Graph Max Independent set = two point number-maximum match
//Hungary#include <bits/stdc++.h>using namespacestd;#defineN 50intUseif[n];//record whether the node in Y uses 0 to indicate no access, 1 for accessintLink[n];//Record the node of the X currently connected to the Y nodeintMat[n][n];//record the edges of the connection x and Y, if there is an edge between I and J is 1, otherwise 0intGN, GM;//number of points in X and y in a binary chartintCanintt) {inti; for(i =1; I <= GM; i++) { if(Useif[i] = =0&&Mat[t][i]) {Useif[i]=1; if(Link[i] = =-1||can (Link[i])) {Link[i]=T; return 1; } } } return 0;}intMaxmatch () {intI, Num; Num=0; memset (Link,0xFF,sizeof(link)); for(i =1; I <= GN; i++) {memset (Useif,0,sizeof(Useif)); if(Can (i)) {num++; } } returnnum;}intMain () {intTCASE; scanf ("%d", &TCASE); while(tcase--) { intN, K; intu, v; scanf ("%d%d", &n, &k); GN= GM =N; Memset (Mat,0,sizeof(MAT)); for(inti =1; I <= K; i++) {scanf ("%d%d", &u, &v); MAT[U][V]=1; } for(inti =1; I <= N; i++) { for(intj =1; J <= N; J + +) {Mat[i][j]= Mat[i][j] ^1; } } intAns = n *2; Ans-=Maxmatch (); printf ("%d\n", ans); }}
View Code
GYM-101915D largest group largest group