結果
問題 | No.1473 おでぶなおばけさん |
ユーザー | 小野寺健 |
提出日時 | 2021-04-26 08:49:58 |
言語 | Java21 (openjdk 21) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,482 bytes |
コンパイル時間 | 3,713 ms |
コンパイル使用メモリ | 78,712 KB |
実行使用メモリ | 81,160 KB |
最終ジャッジ日時 | 2023-09-18 00:14:47 |
合計ジャッジ時間 | 39,452 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 126 ms
55,712 KB |
testcase_01 | AC | 128 ms
55,924 KB |
testcase_02 | AC | 1,920 ms
80,780 KB |
testcase_03 | AC | 1,371 ms
78,564 KB |
testcase_04 | AC | 1,205 ms
71,132 KB |
testcase_05 | AC | 907 ms
66,868 KB |
testcase_06 | AC | 1,728 ms
79,048 KB |
testcase_07 | AC | 1,655 ms
80,824 KB |
testcase_08 | AC | 1,951 ms
81,160 KB |
testcase_09 | AC | 1,542 ms
80,884 KB |
testcase_10 | AC | 1,072 ms
70,860 KB |
testcase_11 | AC | 1,194 ms
70,844 KB |
testcase_12 | AC | 1,025 ms
71,168 KB |
testcase_13 | AC | 857 ms
68,708 KB |
testcase_14 | AC | 670 ms
65,236 KB |
testcase_15 | AC | 1,056 ms
70,856 KB |
testcase_16 | AC | 1,131 ms
70,440 KB |
testcase_17 | AC | 364 ms
58,784 KB |
testcase_18 | AC | 451 ms
60,192 KB |
testcase_19 | AC | 1,185 ms
70,048 KB |
testcase_20 | AC | 1,192 ms
75,888 KB |
testcase_21 | AC | 1,972 ms
74,808 KB |
testcase_22 | AC | 1,319 ms
78,676 KB |
testcase_23 | AC | 1,098 ms
76,132 KB |
testcase_24 | AC | 1,257 ms
75,408 KB |
testcase_25 | TLE | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
testcase_29 | -- | - |
testcase_30 | -- | - |
testcase_31 | -- | - |
testcase_32 | -- | - |
testcase_33 | -- | - |
testcase_34 | -- | - |
testcase_35 | -- | - |
testcase_36 | -- | - |
testcase_37 | -- | - |
testcase_38 | -- | - |
testcase_39 | -- | - |
testcase_40 | -- | - |
testcase_41 | -- | - |
testcase_42 | -- | - |
testcase_43 | -- | - |
testcase_44 | -- | - |
testcase_45 | -- | - |
testcase_46 | -- | - |
testcase_47 | -- | - |
testcase_48 | -- | - |
ソースコード
package yukicoder; import java.util.Scanner; import java.util.List; import java.util.ArrayList; public class No1473_2 { private static class Q { public int i; public long d; public Q(int i, long d) { this.i = i; this.d = d; } } private static int n; private static List<List<Q>> V; public static void main(String[] args) { Scanner scan = new Scanner(System.in); n = scan.nextInt(); int m = scan.nextInt(); V = new ArrayList<List<Q>>(); for (int i = 0; i < n; i++) { V.add(new ArrayList<Q>()); } long max_d = 0; for (int i=0; i < m; i++) { int s = scan.nextInt() - 1; int t = scan.nextInt() - 1; long d = scan.nextLong(); V.get(s).add(new Q(t, d)); V.get(t).add(new Q(s, d)); max_d = Math.max(max_d, d); } scan.close(); Q l = new Q(0, 0L), r = new Q(0, max_d + 1); while (r.d - l.d > 1) { long mid = (r.d + l.d) / 2; int c = bfs(mid); if (c == 0) { r.d = mid; r.i = 0; } else { l.d = mid; l.i = c; } } System.out.println(String.format("%d %d", l.d,l.i)); } private static int bfs(long w) { boolean[] B = new boolean[n]; List<Integer[]> q = new ArrayList<Integer[]>(); q.add(new Integer[] {0, 0}); B[0] = true; while (q.size() > 0) { Integer[] v = q.remove(0); if (v[0] == n-1) { return v[1]; } B[v[0]] = true; for (Q i : V.get(v[0])) { if (i.d >= w && !B[i.i]) { q.add(new Integer[] {i.i, v[1] + 1}); } } } return 0; } }