很神奇的kruakal用法,枚举最小的边,然后kruakal找到一条可行路径,记录差值比较
看了解题报告都有点晕,自己绝对想不到这种用法。。。。。
code:
#include <cstdio>
#include <algorithm>
using namespace std;
const int INF = 0x3fffffff;
int n,m,fa[201],rank[201];
struct node
{
int from,to,w;
}p[1001];
bool cmp(const node x,const node y)
{
return x.w<y.w;
}
int find(int k)
{
if(k!=fa[k])
{
fa[k]=find(fa[k]);
}
return fa[k];
}
void merge(int x,int y......
阅读全文