import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string; auto rdsp(){return readln.splitter;} void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;} void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);} void writeA(T)(size_t n,T t){foreach(i,v;t.enumerate){write(v);if(i b.wt")(Array!Edge(Edge(sent, s, 0))); while (!q.empty) { auto e = q.front; q.removeFront(); if (prev[e.dst] != sent) continue; prev[e.dst] = e.src; foreach (f; g[e.dst]) { auto w = e.wt + f.wt; if (dist[f.dst] > w) { dist[f.dst] = w; q.insert(Edge(f.src, f.dst, w)); } } } } auto dijkstra(ref Graph g, Node s) { Wt[] dist; Node[] prev; dijkstra(g, s, dist, prev); return dist; } } auto dijkstra(G, N)(G g, N s) { return Dijkstra!G.dijkstra(g, s); }