# 【BZOJ4152】The Captain（最短路）

BZOJ

5

2 2

1 1

4 5

7 1

6 7

2

## 题解

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<queue>
using namespace std;
#define ll long long
#define RG register
#define MAX 222222
{
RG int x=0,t=1;RG char ch=getchar();
while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
if(ch=='-')t=-1,ch=getchar();
while(ch<='9'&&ch>='0')x=x*10+ch-48,ch=getchar();
return x*t;
}
int n;
struct Line{int v,next,w;}e[MAX<<2];
int h[MAX],cnt=1;
inline void Add(int u,int v,int w){e[cnt]=(Line){v,h[u],w};h[u]=cnt++;}
struct Node{int x,y,id;}p[MAX];
bool cmp1(Node a,Node b){return a.x<b.x;}
bool cmp2(Node a,Node b){return a.y<b.y;}
int dis[MAX];
bool vis[MAX];
priority_queue<pair<int,int>,vector<pair<int,int> >,greater<pair<int,int> > >Q;
void Dijkstra()
{
Q.push(make_pair(0,1));
pair<int,int> u;
while(!Q.empty())
{
u=Q.top();Q.pop();
if(vis[u.second])continue;
vis[u.second]=true;
dis[u.second]=u.first;
for(int i=h[u.second];i;i=e[i].next)
{
int v=e[i].v;
if(vis[v])continue;
Q.push(make_pair(u.first+e[i].w,v));
}
}
}
int main()
{
sort(&p[1],&p[n+1],cmp1);
for(int i=1;i<n;++i)
{
}
sort(&p[1],&p[n+1],cmp2);
for(int i=1;i<n;++i)
{