結果
問題 | No.1607 Kth Maximum Card |
ユーザー | 👑 hos.lyric |
提出日時 | 2021-07-16 22:08:42 |
言語 | D (dmd 2.106.1) |
結果 |
AC
|
実行時間 | 1,642 ms / 3,500 ms |
コード長 | 2,400 bytes |
コンパイル時間 | 1,924 ms |
コンパイル使用メモリ | 112,420 KB |
実行使用メモリ | 35,796 KB |
最終ジャッジ日時 | 2023-09-04 13:15:17 |
合計ジャッジ時間 | 18,675 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
4,380 KB |
testcase_01 | AC | 1 ms
4,380 KB |
testcase_02 | AC | 2 ms
4,380 KB |
testcase_03 | AC | 2 ms
4,376 KB |
testcase_04 | AC | 1 ms
4,376 KB |
testcase_05 | AC | 1 ms
4,376 KB |
testcase_06 | AC | 2 ms
4,376 KB |
testcase_07 | AC | 1 ms
4,380 KB |
testcase_08 | AC | 1,268 ms
21,816 KB |
testcase_09 | AC | 1,002 ms
22,656 KB |
testcase_10 | AC | 1,291 ms
35,796 KB |
testcase_11 | AC | 168 ms
13,700 KB |
testcase_12 | AC | 929 ms
26,172 KB |
testcase_13 | AC | 104 ms
12,856 KB |
testcase_14 | AC | 131 ms
13,616 KB |
testcase_15 | AC | 765 ms
18,160 KB |
testcase_16 | AC | 100 ms
13,956 KB |
testcase_17 | AC | 35 ms
4,376 KB |
testcase_18 | AC | 394 ms
17,004 KB |
testcase_19 | AC | 227 ms
14,312 KB |
testcase_20 | AC | 351 ms
14,496 KB |
testcase_21 | AC | 360 ms
14,684 KB |
testcase_22 | AC | 1,060 ms
21,052 KB |
testcase_23 | AC | 1,112 ms
18,588 KB |
testcase_24 | AC | 286 ms
14,372 KB |
testcase_25 | AC | 154 ms
13,920 KB |
testcase_26 | AC | 198 ms
14,644 KB |
testcase_27 | AC | 310 ms
14,204 KB |
testcase_28 | AC | 232 ms
14,412 KB |
testcase_29 | AC | 729 ms
16,900 KB |
testcase_30 | AC | 1,642 ms
18,540 KB |
testcase_31 | AC | 655 ms
16,040 KB |
testcase_32 | AC | 311 ms
12,428 KB |
testcase_33 | AC | 317 ms
12,140 KB |
testcase_34 | AC | 300 ms
12,188 KB |
testcase_35 | AC | 296 ms
12,140 KB |
ソースコード
import std.conv, std.functional, std.range, std.stdio, std.string; import std.algorithm, std.array, std.bigint, std.bitmanip, std.complex, std.container, std.math, std.mathspecial, std.numeric, std.regex, std.typecons; import core.bitop; class EOFException : Throwable { this() { super("EOF"); } } string[] tokens; string readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; } int readInt() { return readToken.to!int; } long readLong() { return readToken.to!long; } real readReal() { return readToken.to!real; } bool chmin(T)(ref T t, in T f) { if (t > f) { t = f; return true; } else { return false; } } bool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } } int binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; } int lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); } int upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); } void main() { try { for (; ; ) { const N = readInt(); const M = readInt(); const K = readInt(); auto A = new int[M]; auto B = new int[M]; auto C = new int[M]; foreach (i; 0 .. M) { A[i] = readInt() - 1; B[i] = readInt() - 1; C[i] = readInt(); } auto G = new int[][N]; foreach (i; 0 .. M) { G[A[i]] ~= i; G[B[i]] ~= i; } int lo = -1, hi = C.maxElement; for (; lo + 1 < hi; ) { const mid = (lo + hi) / 2; DList!int que; auto dist = new int[N]; dist[] = N; dist[0] = 0; que ~= 0; for (; !que.empty; ) { const u = que.front; que.removeFront; foreach (i; G[u]) { const v = A[i] ^ B[i] ^ u; if (C[i] <= mid) { if (chmin(dist[v], dist[u])) { que.insertFront(v); } } else { if (chmin(dist[v], dist[u] + 1)) { que.insertBack(v); } } } } ((dist[N - 1] < K) ? hi : lo) = mid; } writeln(hi); } } catch (EOFException e) { } }