# bzoj4289 Tax

N<=100000
M<=200000

4 5
1 2 5
1 3 2
2 3 1
2 4 4
3 4 8

## Sample Output

12

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
#include <cstdlib>
#define REP(i,k,n)  for(int i=k;i<=n;i++)
#define MAXN 400040
using namespace std;
int x=0,f=1;
char ch=getchar();
for(;!isdigit(ch);ch=getchar())
if(ch=='-')
f=-1;
for(;isdigit(ch);ch=getchar())
x=x*10+ch-'0';
return x*f;
}
int n,m;
int S,T;
int vis[400010];
long long dis[400010];
struct edge{
int id,va;
}st[MAXN*2];
struct node{
int a;
long long b;
bool operator <(const node &x)const{
return b>x.b;
}
};
priority_queue<node> Q;
inline int change(int x){
if(x%2==1)  return x+1;
return x-1;
}
inline void adl(int a,int b,int c){
total++;
to[total]=b;
val[total]=c;
return ;
}
inline void Adl(int a,int b,int c){
Total++;
To[Total]=b;
Val[Total]=c;
return ;
}
inline bool cmp(edge a,edge b){
return a.va<b.va;
}
inline void solve(int u){
int cnt=0;
sort(st+1,st+cnt+1,cmp);//对于u的所有出边排序
return ;
}
inline long long Dijkstra(){
memset(dis,0x7f,sizeof(dis));
dis[S]=0;
node p;
p.a=S,p.b=0;
Q.push(p);
while(!Q.empty()){
int u=Q.top().a;Q.pop();
if(vis[u])  continue;
vis[u]=1;
if(dis[To[e]]>dis[u]+Val[e]){
dis[To[e]]=dis[u]+Val[e];
node q;
q.a=To[e],q.b=dis[To[e]];
Q.push(q);
}
}
return dis[T];
}
int main(){
in(n),in(m);
int a,b,c;
S=0,T=total+1;
for(int i=1;i<=n;i++)  solve(i);
printf("%d",Dijkstra());
return 0;
}
/*
4 5
1 2 5
1 3 2
2 3 1
2 4 4
3 4 8
*/

posted @ 2019-01-29 10:30  Dijkstra·Liu  阅读(404)  评论(2编辑  收藏  举报