BZOJ 2346: [Baltic 2011]Lamp Dijkstra
Code: #include <bits/stdc++.h> #define N 600 #define M 1000000 #define inf 1000000000 #define setIO(s) freopen(s".in","r",stdin) using namespace std; char str[N]; int id[N][N],tot,edges,s; int hd[M],to[M],nex[M],val[M],done[M],d[M]; void addedge(int u,int v,int c) { nex[++edges]=hd[u],hd[u]=edges,to[edges]=v,val[edges]=c; swap(u,v); nex[++edges]=hd[u],hd[u]=edges,to[edges]=v,val[edges]=c; } struct P { int u,dis; P(int u=0,int dis=0):u(u),dis(dis){} bool operator<(P b) const { return b.dis<dis; } }; priority_queue<P>q; void Dijkstra() { for(int i=0;i<M;++i) d[i]=inf; for(d[s]=0,q.push(P(s,0));