結果
問題 | No.812 Change of Class |
ユーザー | tenten |
提出日時 | 2022-04-21 16:17:17 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,703 bytes |
コンパイル時間 | 2,474 ms |
コンパイル使用メモリ | 80,436 KB |
実行使用メモリ | 90,148 KB |
最終ジャッジ日時 | 2024-06-22 19:43:56 |
合計ジャッジ時間 | 68,970 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 946 ms
79,252 KB |
testcase_01 | AC | 314 ms
60,712 KB |
testcase_02 | AC | 631 ms
64,252 KB |
testcase_03 | AC | 851 ms
80,260 KB |
testcase_04 | AC | 1,025 ms
82,188 KB |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | AC | 78 ms
51,340 KB |
testcase_08 | AC | 67 ms
50,300 KB |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | AC | 211 ms
64,808 KB |
testcase_12 | WA | - |
testcase_13 | AC | 57 ms
50,120 KB |
testcase_14 | AC | 57 ms
50,396 KB |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | WA | - |
testcase_35 | AC | 513 ms
69,044 KB |
testcase_36 | AC | 310 ms
61,520 KB |
testcase_37 | AC | 906 ms
64,756 KB |
testcase_38 | AC | 144 ms
54,468 KB |
testcase_39 | AC | 942 ms
64,876 KB |
testcase_40 | AC | 353 ms
61,480 KB |
testcase_41 | AC | 134 ms
54,328 KB |
testcase_42 | AC | 1,444 ms
65,792 KB |
testcase_43 | AC | 402 ms
63,220 KB |
testcase_44 | AC | 1,246 ms
64,692 KB |
testcase_45 | AC | 297 ms
61,364 KB |
testcase_46 | AC | 392 ms
63,320 KB |
testcase_47 | AC | 1,146 ms
64,792 KB |
testcase_48 | AC | 1,092 ms
65,920 KB |
testcase_49 | AC | 593 ms
62,600 KB |
testcase_50 | AC | 135 ms
55,616 KB |
testcase_51 | AC | 502 ms
62,332 KB |
testcase_52 | AC | 775 ms
63,564 KB |
testcase_53 | AC | 416 ms
65,464 KB |
testcase_54 | AC | 415 ms
64,348 KB |
testcase_55 | AC | 1,185 ms
78,528 KB |
testcase_56 | AC | 1,288 ms
86,888 KB |
testcase_57 | AC | 1,210 ms
83,400 KB |
testcase_58 | AC | 872 ms
70,396 KB |
testcase_59 | AC | 1,432 ms
90,008 KB |
testcase_60 | AC | 56 ms
50,316 KB |
testcase_61 | AC | 57 ms
50,324 KB |
testcase_62 | AC | 56 ms
50,312 KB |
ソースコード
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); int n = sc.nextInt(); int m = sc.nextInt(); ArrayList<ArrayList<Integer>> graph = new ArrayList<>(); for (int i = 0; i < n; i++) { graph.add(new ArrayList<>()); } for (int i = 0; i < m; i++) { int a = sc.nextInt() - 1; int b = sc.nextInt() - 1; graph.get(a).add(b); graph.get(b).add(a); } int q = sc.nextInt(); int[] costs = new int[n]; PriorityQueue<Path> queue = new PriorityQueue<>(); TreeMap<Integer, Integer> days = new TreeMap<>(); int value = 1; for (int i = 0; i < 30; i++) { days.put(value, i); value *= 2; } StringBuilder sb = new StringBuilder(); for (int i = 0; i < q; i++) { int x = sc.nextInt() - 1; Arrays.fill(costs, Integer.MAX_VALUE); queue.add(new Path(x, 0)); int max = 0; int count = 0; while (queue.size() > 0) { Path p = queue.poll(); if (costs[p.idx] < p.value) { continue; } costs[p.idx] = p.value; max = p.value; count++; for (int y : graph.get(p.idx)) { queue.add(new Path(y, p.value + 1)); } } sb.append(count - 1).append(" ").append(days.ceilingEntry(max).getValue()).append("\n"); } System.out.print(sb); } static class Path implements Comparable<Path> { int idx; int value; public Path(int idx, int value) { this.idx = idx; this.value = value; } public int compareTo(Path another) { return value - another.value; } } } class Scanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); public Scanner() throws Exception { } public int nextInt() throws Exception { return Integer.parseInt(next()); } public long nextLong() throws Exception { return Long.parseLong(next()); } public double nextDouble() throws Exception { return Double.parseDouble(next()); } public String next() throws Exception { if (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } return st.nextToken(); } }