# BZOJ4152: [AMPPZ2014]The Captain

BZOJ4152: [AMPPZ2014]The Captain

5
2 2
1 1
4 5
7 1
6 7

## Sample Output

2

$O(n^2)\text{的Force？}\tan(\frac{\pi}{2}+k\pi),k\in Z$。。。

#include<iostream>
#include<algorithm>
#include<cstdio>
#include<queue>
#define MAXN 200010
#define MAX (1LL<<61)
using namespace std;
int n,s,t,c=1;
long long path[MAXN];
bool vis[MAXN];
struct Point{
int x,y,id;
}point[MAXN];
struct Edge{
int next,to;
long long w;
}a[MAXN<<2];
struct node{
int x,dis;
bool operator <(const node &p)const{
return dis>p.dis;
}
};
priority_queue<node> q;
int date=0,w=1;char c=0;
while(c<'0'||c>'9'){if(c=='-')w=-1;c=getchar();}
while(c>='0'&&c<='9'){date=date*10+c-'0';c=getchar();}
return date*w;
}
inline bool cmp1(const Point &p,const Point &q){
return p.x<q.x;
}
inline bool cmp2(const Point &p,const Point &q){
return p.y<q.y;
}
inline int relax(int u,int v,long long w){
if(path[v]>path[u]+w){
path[v]=path[u]+w;
return 1;
}
return 0;
}
inline void add(int u,int v,int w){
}
void dijkstra(){
node u,v;
for(int i=1;i<=n;i++){path[i]=MAX;vis[i]=false;}
u.x=s;u.dis=path[s]=0;
q.push(u);
while(!q.empty()){
u=q.top();
q.pop();
if(!vis[u.x]){
vis[u.x]=true;
v.x=a[i].to;
if(!vis[v.x]){
path[v.x]=min(path[v.x],path[u.x]+a[i].w);
v.dis=u.dis+a[i].w;
q.push(v);
}
}
}
}
}
void work(){
dijkstra();
printf("%lld\n",path[t]);
}
void init(){
s=1;t=n;
for(int i=1;i<=n;i++){
point[i].id=i;
}
sort(point+1,point+n+1,cmp1);
sort(point+1,point+n+1,cmp2);