結果
問題 | No.1473 おでぶなおばけさん |
ユーザー | 小野寺健 |
提出日時 | 2021-04-26 08:46:06 |
言語 | Java21 (openjdk 21) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,493 bytes |
コンパイル時間 | 5,210 ms |
コンパイル使用メモリ | 75,040 KB |
実行使用メモリ | 71,240 KB |
最終ジャッジ日時 | 2023-09-18 00:08:45 |
合計ジャッジ時間 | 42,373 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 119 ms
44,652 KB |
testcase_01 | AC | 120 ms
39,876 KB |
testcase_02 | TLE | - |
testcase_03 | AC | 1,399 ms
63,852 KB |
testcase_04 | AC | 1,270 ms
56,936 KB |
testcase_05 | AC | 945 ms
52,064 KB |
testcase_06 | AC | 1,852 ms
63,888 KB |
testcase_07 | AC | 1,736 ms
66,460 KB |
testcase_08 | TLE | - |
testcase_09 | AC | 1,627 ms
66,420 KB |
testcase_10 | AC | 1,026 ms
58,640 KB |
testcase_11 | AC | 1,142 ms
60,000 KB |
testcase_12 | AC | 1,033 ms
59,284 KB |
testcase_13 | AC | 818 ms
54,224 KB |
testcase_14 | AC | 674 ms
54,344 KB |
testcase_15 | AC | 1,058 ms
57,160 KB |
testcase_16 | AC | 1,065 ms
56,732 KB |
testcase_17 | AC | 323 ms
45,704 KB |
testcase_18 | AC | 410 ms
46,460 KB |
testcase_19 | AC | 1,136 ms
56,232 KB |
testcase_20 | AC | 1,225 ms
62,504 KB |
testcase_21 | TLE | - |
testcase_22 | AC | 1,423 ms
62,876 KB |
testcase_23 | AC | 1,089 ms
62,596 KB |
testcase_24 | AC | 1,369 ms
61,300 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}); while (q.size() > 0) { Integer[] v = q.remove(0); if (v[0] == n-1) { return v[1]; } if (B[v[0]]) { continue; } B[v[0]] = true; for (Q i : V.get(v[0])) { if (i.d >= w) { q.add(new Integer[] {i.i, v[1] + 1}); } } } return 0; } }