2018"百度之星"程序设计大赛 - 资格赛 - 整数规划 (最小权匹配-KM算法)

 

http://acm.hdu.edu.cn/showproblem.php?pid=6346

 

2018

 

 

#include 
#include 
#include 
using namespace std;
#define  LL long long
const LL N = 222;
const LL inf = 0x3f3f3f3f3f3f3f3f;
LL n;
LL val[N][N];
LL lx[N],ly[N];
LL linky[N];
LL pre[N];
bool vis[N];
bool visx[N],visy[N];
LL slack[N];

void bfs(LL k){
    LL px, py = 0,yy = 0, d;
    memset(pre, 0, sizeof(LL) * (n+2));
    memset(slack, inf, sizeof(LL) * (n+2));
    linky[py]=k;
    do{
        px = linky[py],d = inf, vis[py] = 1;
        for(LL i = 1; i <= n; i++)
            if(!vis[i]){
                if(slack[i] > lx[px] + ly[i] - val[px][i])
                    slack[i] = lx[px] + ly[i] -val[px][i], pre[i]=py;
                if(slack[i]

 

你可能感兴趣的:(HDU,二分图)