import std.stdio, std.conv; import std.algorithm, std.range, std.random; import std.string, std.array, std.container, std.bigint; import std.typecons; alias E = Tuple!(int, int, double); int[] tpor(int n, E[] e) { bool[] used = new bool[n]; int[] res; while (res.length != n) { foreach (i; 0..n) { bool f = true; foreach (v; e) { if (v[1] != i) continue; if (used[v[0]]) continue; f = false; break; } if (!f) continue; res ~= i; used[i] = true; } } return res; } int main() { int n, m; readf("%d %d\n", &n, &m); double[][] g = new double[][](n, n); foreach (i; 0..n) { foreach (j; 0..n) { g[i][j] = 0; } } E[] ed; foreach (i; 0..m) { int a, b; double c; readf("%d %d %f\n", &a, &b, &c); ed ~= tuple(a, b, c); // g[a][b] = c / 100.0; } auto l = tpor(n, ed); int[] rl = new int[](n); foreach (i; 0..n) { rl[l[i]] = i; } foreach (e; ed) { g[rl[e[0]]][rl[e[1]]] = e[2] / 100.0; } double[][] dp = new double[][](n, 1<