/**
[二分匹配]poj 1719 Shooting Contest
r*c 的格子矩阵,有C发子弹,每列格子有2个白色的方块,
每一列打一个白色格子,才能把所有的行全部打到,
如果行全部打到而且有多余的列,那么这列随便打一个方块就可以了,
二分匹配,输出匹配方案
*/
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <algorithm>
using namespace std;
const int MAXN = 1001;
int uN,vN;
bool g[MAXN][MAXN];
int xM[MAXN],yM[MAXN];
bool chk[MAXN];
bool dfs(int u)
{
for(int v = 1; v <= vN; ++v)
if(g[u][v] && !chk[v])
{
chk[v] = 1;
if(yM[v] == -1 || dfs(yM[v]))
{
yM[v] = u;
xM[u] = v;
return 1;
}
}
return 0;
}
int MaxMatch()
{
int u,ret = 0;
memset(xM,-1,sizeof(xM));
memset(yM,-1,sizeof(yM));
for(u