Welcome, Guest! Sign Up RSS

Clever Space

Friday, 11.22.2024
Main » 2013 » October » 18

题目大意:

在一个无向图中有T条边,每个点至少和两条边相连,每条边有一个长度,询问从给定起点到给定终点的包含N条边的路最短是多长。

问题规模:

1<=N<=1000000000, 1<=T<=100

... Read more »

Views: 389 | Added by: dhy0077 | Date: 10.18.2013

二分答案+BCJ

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<set>
#include<algorithm>
#include<map>
#include<vector>
#include<queue>
#include<iostream>
#include<string>
#include<cmath>
#define N 300010
#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 x[N],y[N],f[N],n,m,X,flag[N];
int getf(int x){if (f[x]!=x) f[x]=getf(f[x]);return f[x];}
bool check(int k)
{
  int i;
  FOR(i,1,n) f[i]=i;
  memset(flag,0,sizeof(flag));
  FOR(i,1,m)
  {
    if (x[i]<=k||y[i]<=k) continue;
    int fa=getf(x[i]),fb=getf(y[i]) ... Read more »
Views: 428 | Added by: dhy0077 | Date: 10.18.2013