結果
問題 | No.1473 おでぶなおばけさん |
ユーザー | daut-dlang |
提出日時 | 2021-04-09 22:12:04 |
言語 | D (dmd 2.106.1) |
結果 |
AC
|
実行時間 | 227 ms / 2,000 ms |
コード長 | 2,950 bytes |
コンパイル時間 | 879 ms |
コンパイル使用メモリ | 132,436 KB |
実行使用メモリ | 29,744 KB |
最終ジャッジ日時 | 2024-06-22 11:11:49 |
合計ジャッジ時間 | 9,299 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
6,816 KB |
testcase_01 | AC | 1 ms
6,944 KB |
testcase_02 | AC | 217 ms
28,120 KB |
testcase_03 | AC | 204 ms
25,472 KB |
testcase_04 | AC | 105 ms
20,648 KB |
testcase_05 | AC | 40 ms
11,044 KB |
testcase_06 | AC | 211 ms
27,756 KB |
testcase_07 | AC | 198 ms
29,716 KB |
testcase_08 | AC | 209 ms
28,648 KB |
testcase_09 | AC | 227 ms
29,316 KB |
testcase_10 | AC | 141 ms
21,396 KB |
testcase_11 | AC | 135 ms
28,744 KB |
testcase_12 | AC | 138 ms
24,476 KB |
testcase_13 | AC | 86 ms
14,336 KB |
testcase_14 | AC | 59 ms
13,780 KB |
testcase_15 | AC | 123 ms
19,980 KB |
testcase_16 | AC | 126 ms
23,808 KB |
testcase_17 | AC | 11 ms
6,940 KB |
testcase_18 | AC | 16 ms
6,944 KB |
testcase_19 | AC | 140 ms
22,308 KB |
testcase_20 | AC | 157 ms
23,836 KB |
testcase_21 | AC | 180 ms
27,032 KB |
testcase_22 | AC | 175 ms
24,032 KB |
testcase_23 | AC | 148 ms
24,264 KB |
testcase_24 | AC | 149 ms
24,128 KB |
testcase_25 | AC | 199 ms
24,120 KB |
testcase_26 | AC | 207 ms
27,500 KB |
testcase_27 | AC | 68 ms
15,788 KB |
testcase_28 | AC | 206 ms
29,744 KB |
testcase_29 | AC | 178 ms
23,464 KB |
testcase_30 | AC | 221 ms
29,392 KB |
testcase_31 | AC | 212 ms
29,092 KB |
testcase_32 | AC | 226 ms
28,644 KB |
testcase_33 | AC | 169 ms
24,800 KB |
testcase_34 | AC | 80 ms
15,220 KB |
testcase_35 | AC | 101 ms
18,600 KB |
testcase_36 | AC | 140 ms
22,440 KB |
testcase_37 | AC | 152 ms
24,232 KB |
testcase_38 | AC | 27 ms
9,080 KB |
testcase_39 | AC | 122 ms
23,788 KB |
testcase_40 | AC | 120 ms
24,420 KB |
testcase_41 | AC | 98 ms
22,368 KB |
testcase_42 | AC | 99 ms
22,576 KB |
testcase_43 | AC | 182 ms
28,016 KB |
testcase_44 | AC | 172 ms
28,140 KB |
testcase_45 | AC | 168 ms
28,016 KB |
testcase_46 | AC | 153 ms
24,920 KB |
testcase_47 | AC | 191 ms
24,964 KB |
testcase_48 | AC | 167 ms
23,824 KB |
ソースコード
import std.stdio, std.conv, std.functional, std.string; import std.algorithm, std.array, std.container, std.range, std.typecons; import std.bigint, std.numeric, std.math, std.random; import core.bitop; string FMT_F = "%.10f"; static File _f; void file_io(string fn) { _f = File(fn, "r"); } static string[] s_rd; T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; } T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; } T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; } T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; } T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; } T[] RDA(T = long)(T fix = 0) { if (_f.isOpen) return _RDA!T(_f, fix); else return _RDA!T(fix); } size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;} size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; } void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); } bool inside(T)(T x, T b, T e) { return x >= b && x < e; } T lcm(T)(T x, T y) { return x * (y / gcd(x, y)); } long mod = 10^^9 + 7; //long mod = 998_244_353; //long mod = 1_000_003; void moda(ref long x, long y) { x = (x + y) % mod; } void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; } void modm(ref long x, long y) { x = (x * y) % mod; } void modpow(ref long x, long y) { if (!y) { x = 1; return; } auto t = x; x.modpow(y>>1); x.modm(x); if (y&1) x.modm(t); } void modd(ref long x, long y) { y.modpow(mod - 2); x.modm(y); } void main() { auto n = RD; auto m = RD; auto edges = new long[][][](n); foreach (i; 0..m) { auto s = RD-1; auto t = RD-1; auto d = RD; edges[s] ~= [t, d]; edges[t] ~= [s, d]; } long ans1; { BinaryHeap!(Array!(long[]), "a[0] < b[0]") q; q.insert([long.max, 0]); auto dist = new long[](n); dist[0] = long.max; while (!q.empty) { auto nd = q.front; q.popFront; auto w = nd[0]; auto u = nd[1]; foreach (e; edges[u]) { auto v = e[0]; auto d = e[1]; if (min(w, d) > dist[v]) { dist[v] = min(w, d); q.insert([min(w, d), v]); } } } ans1 = dist[n-1]; debug writeln(dist); } long ans2; { long[] q = [0]; auto dist = new long[](n); dist[] = long.max; dist[0] = 0; while (!q.empty) { auto u = q.front; q.popFront; auto d = dist[u]; foreach (e; edges[u]) { auto v = e[0]; auto w = e[1]; if (w < ans1) continue; if (d+1 < dist[v]) { dist[v] = d+1; q ~= v; } } } ans2 = dist[n-1]; debug writeln(dist); } writeln(ans1, " ", ans2); stdout.flush; debug readln; }