結果
問題 | No.1473 おでぶなおばけさん |
ユーザー | daut-dlang |
提出日時 | 2021-04-09 22:12:04 |
言語 | D (dmd 2.107.1) |
結果 |
AC
|
実行時間 | 281 ms / 2,000 ms |
コード長 | 2,950 bytes |
コンパイル時間 | 1,430 ms |
コンパイル使用メモリ | 119,520 KB |
実行使用メモリ | 29,988 KB |
最終ジャッジ日時 | 2023-09-04 12:32:43 |
合計ジャッジ時間 | 11,512 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
4,376 KB |
testcase_01 | AC | 1 ms
4,380 KB |
testcase_02 | AC | 274 ms
27,712 KB |
testcase_03 | AC | 237 ms
24,968 KB |
testcase_04 | AC | 133 ms
20,904 KB |
testcase_05 | AC | 50 ms
12,344 KB |
testcase_06 | AC | 272 ms
27,928 KB |
testcase_07 | AC | 270 ms
29,928 KB |
testcase_08 | AC | 277 ms
29,460 KB |
testcase_09 | AC | 270 ms
29,988 KB |
testcase_10 | AC | 160 ms
22,012 KB |
testcase_11 | AC | 161 ms
27,752 KB |
testcase_12 | AC | 164 ms
24,568 KB |
testcase_13 | AC | 99 ms
15,216 KB |
testcase_14 | AC | 70 ms
14,476 KB |
testcase_15 | AC | 139 ms
18,996 KB |
testcase_16 | AC | 137 ms
24,204 KB |
testcase_17 | AC | 12 ms
4,380 KB |
testcase_18 | AC | 19 ms
6,320 KB |
testcase_19 | AC | 163 ms
22,716 KB |
testcase_20 | AC | 215 ms
25,112 KB |
testcase_21 | AC | 234 ms
27,800 KB |
testcase_22 | AC | 238 ms
24,656 KB |
testcase_23 | AC | 219 ms
25,432 KB |
testcase_24 | AC | 198 ms
25,500 KB |
testcase_25 | AC | 238 ms
25,300 KB |
testcase_26 | AC | 245 ms
27,576 KB |
testcase_27 | AC | 83 ms
16,776 KB |
testcase_28 | AC | 265 ms
29,704 KB |
testcase_29 | AC | 222 ms
24,940 KB |
testcase_30 | AC | 264 ms
29,856 KB |
testcase_31 | AC | 270 ms
28,132 KB |
testcase_32 | AC | 281 ms
28,996 KB |
testcase_33 | AC | 219 ms
25,332 KB |
testcase_34 | AC | 100 ms
15,640 KB |
testcase_35 | AC | 125 ms
19,228 KB |
testcase_36 | AC | 165 ms
22,984 KB |
testcase_37 | AC | 190 ms
25,080 KB |
testcase_38 | AC | 34 ms
9,720 KB |
testcase_39 | AC | 139 ms
24,648 KB |
testcase_40 | AC | 139 ms
25,432 KB |
testcase_41 | AC | 114 ms
23,240 KB |
testcase_42 | AC | 116 ms
23,592 KB |
testcase_43 | AC | 202 ms
28,748 KB |
testcase_44 | AC | 203 ms
28,724 KB |
testcase_45 | AC | 205 ms
28,612 KB |
testcase_46 | AC | 186 ms
25,264 KB |
testcase_47 | AC | 229 ms
25,100 KB |
testcase_48 | AC | 214 ms
24,536 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; }