Test instructions
n individuals, there are two kinds of people, m to intimate relationship, ask at least delete several people reach no intimacy.
Ideas:
Maximum match = minimum Independent set, delete the person's impact on the maximum number of matches, if there is no impact, delete does not matter, if there is an impact on the thief delete;
similar to HDU1281;
Processing can be removed this point after the augmentation, if the search to the augmentation is not affected, can not find the augmentation is affected.
Error is a dichotomy, I want to delete two points, two sets of points can be deleted, * unilaterally deleted a *.
Error in the unconscious preference for a picture, in fact, two graphs, the picture is very independent, the status of equality and importance.
#include <bits/stdc++.h>//using namespace::std;
typedef pair<int,int> PII; #include <cstdio> #include <iostream> #include <string.h> #include <algorithm> using namespace
Std
const int N=2E2+10;
BOOL Ma[n][n];
int cx[n],cy[n],n,m;
BOOL Vis[n],col[n],deleted[n];
BOOL Findpatex (int u) {if (Deleted[u]) return false;
for (int i=0;i<n;i++) {if (Ma[u][i]&&!vis[i]&&!deleted[i]&&col[i]) {
Vis[i]=true; if (cy[i]==-1| |
Findpatex (Cy[i])) {cx[u]=i;
Cy[i]=u;
return true;
}}} return false;
} bool Findpatey (int u) {if (Deleted[u]) return false;
for (int i=0;i<n;i++) {if (Ma[u][i]&&!vis[i]&&!deleted[i]&&!col[i]) {
Vis[i]=true; if (cx[i]==-1| |
Findpatey (Cx[i])) {cx[i]=u;
Cy[u]=i; return true;
}}} return false;
} int main () {int T;
scanf ("%d", &t);
while (t--) {int u,v;
scanf ("%d%d", &n,&m);
for (int i=0;i<n;i++) scanf ("%d", &col[i]);
memset (ma,0,sizeof (MA));
while (m--) {scanf ("%d%d", &u,&v);
if (Col[u]!=col[v]) ma[u][v]=ma[v][u]=1;
} int ans=0;
memset (cx,-1,sizeof (CX));
memset (cy,-1,sizeof (CY));
memset (deleted,false,sizeof (deleted)); for (int i=0;i<n;i++) {if (!col[i]&&cx[i]==-1) {memset (vis,0,si
Zeof (VIS));
Ans+=findpatex (i);
}} printf ("%d", ans);
int temp;
for (int i=0;i<n;i++) {if (!col[i]) {if (cx[i]!=-1) {
Temp=cx[i];Cx[i]=cy[temp]=-1;
memset (vis,0,sizeof (VIS));
Deleted[i]=true;
if (Findpatey (temp)) Deleted[i]=false;
else printf ("%d", I); }} else {if (cy[i]!=-1) {Temp=cy
[i];
Cx[temp]=cy[i]=-1;
Deleted[i]=true;
memset (vis,0,sizeof (VIS));
if (Findpatex (temp)) Deleted[i]=false;
else printf ("%d", I);
}}} puts ("");
} return 0;
}