Welcome, Guest! Sign Up RSS

Clever Space

Friday, 11.22.2024
Main » 2013 » October » 12

3阶:
0 0 1
1 0 1
0 1 1
4阶:
0 0 0 1
1 0 0 1
0 1 0 1
0 0 1 1


Views: 305 | Added by: dhy0077 | Date: 10.12.2013

krustal最小生成树

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<set>
#include<algorithm>
#include<map>
#include<vector>
#include<queue>
#include<iostream>
#include<string>
#include<cmath>
#define N 100100
#define FOR(i,a,b) for(i=(a);i<=(b);i++)
#define ROF(i,a,b) for(i=(a);i>=(b);i--)
typedef long long LL;
using namespace std;
int f[N],t[N],n,m;
struct node{int x,y,E;};
int cmp(node a,node b){return a.E<b.E;}
node e[N];
int getf(int x)
{
  if (f[x]!=x) f[x]=getf(f[x]);
  return f[x];
}
int main()
{
  scanf("%d%d",&n,&m);
  int i;
  FOR(i,1,n) f[i]=i;
  ... Read more »
Views: 291 | Added by: dhy0077 | Date: 10.12.2013