#include #include using namespace std; #include #include struct bimatch{ int n; vector >G; vectormatch; vectorused; bimatch(int _n=0):n(_n),G(n),match(n),used(n){} void add_edge(int u,int v) { G[u].push_back(v); G[v].push_back(u); } bool dfs(int v) { used[v]=true; for(int u:G[v]) { int w=match[u]; if(w<0||!used[w]&&dfs(w)) { match[v]=u; match[u]=v; return true; } } return false; } int count() { int ans=0; bool flag=true; fill(match.begin(),match.end(),-1); while(flag) { flag=false; fill(used.begin(),used.end(),false); for(int v=0;v>N; bimatch P(2*N); for(int i=0;i>A[i]; for(int j=0;j