Shortest circuit + heap optimization.
The ordinary heap is not good, the use of their own pairs of heap (seemingly Fibonacci heaps also OK?) After all, theoretical complexity)
And then find out how much faster their paired heap is than the cloud God ... I beat him to the template.
And then found that the front T-bar to ignore can be a ...
Data, data, 233.
#include <cctype> #include <algorithm> #include <cstring> #include <cstdlib> #include < Cstdio> #include <iostream> #define REP (i, L, R) for (int i=l; i<=r; i++) #define CLR (x, C) memset (x, C, sizeof (x) ) #define Travel (x) for (Edge *p=fir[x]; p; p=p->n) #define LL Long long #define MAXN 1000009#define maxm 10000009using na Mespace Std;const ll inf= (LL) (0x7fffffff) * (LL) (0x7fffffff), inline ll read () {ll x=0; char Ch=getchar (); while (!isdigit ( CH)) Ch=getchar (), while (IsDigit (CH)) x=x*10+ch-' 0 ', Ch=getchar (); return x;} struct Edge{int y, z; edge *n;} E[MAXM], *FIR[MAXN], *pt=e;inline void Add (ll x, ll y, ll Z) {pt->y=y, pt->z=z, PT-&G T;n=fir[x], fir[x]=pt++;} struct Node{int l, r, ch; node () {l=r=ch;}} h[maxn];int N, M;ll D[MAXN]; BOOL F[maxn];int roof=0;int Join (int v, int u) {if (D[v]<d[u]) swap (V, u); h[v].l=u, h[v].r=h[u].ch, H[h[u].ch].l=v;h[u] . Ch=v;return u;} void push (int v) {if (!roof) roof=v; else roof=join (roof, v);} void update (int v) {if (v!=roof) {if(h[h[v].l].ch==v) H[h[v].l].ch=h[v].r;else h[h[v].l].r=h[v].r;if (H[V].R) h[h[v].r].l=h[v].l;h[v].l=h[v].r=0;roof= Join (roof, v);}} int ST[MAXN], top;void pop () {if (!h[roof].ch) roof=0; else {top=0; int t=h[roof].ch;while (t) if (H[T].R) {int K=H[H[T].R]. R;int V=h[t].r;h[t].l=h[t].r=h[v].l=h[v].r=0;st[++top]=join (t, v); t=k;} else {st[++top]=t; h[t].l=h[t].r=0; break;} Roof=st[top];rep (i, 1, top-1) roof=join (roof, st[i]);}} void Dijstra () {CLR (f, 0); d[1]=0; Rep (i, 2, N) d[i]=inf; push (1); F[1]=true;rep (i, 1, n) {int x=roof; pop (); F[x]=0;if (x== N) break;travel (x) if (d[p->y]>d[x]+ (LL) (P->z)) {d[p->y]=d[x]+ (LL) (p->z), if (!f[p->y]) push (p-> Y), f[p->y]=1; else update (p->y);}}} int main () {N=read (), M=read (), ll T=read (), Rxa=read (), Rxc=read (), Rya=read (), Ryc=read (), Rp=read (), x, Y, A, b;/* rep (i, 1, t) {x= (X*RXA+RXC)%rp;y= (Y*RYA+RYC)%rp;a=min (x%n+1, y%n+1); B=max (y%n+1, y%n+1); Add (A, B, 1e8-100*a);} */rep (i, 1, m-t) {x=read (), Y=read (); ADD (x, Y, read ());} Dijstra ();p rintf ("%Lld\n ", D[n]); return 0;}
BZOJ-3040 Shortest Path