結果
問題 | No.812 Change of Class |
ユーザー | 👑 hos.lyric |
提出日時 | 2019-04-19 20:27:20 |
言語 | D (dmd 2.106.1) |
結果 |
AC
|
実行時間 | 541 ms / 4,000 ms |
コード長 | 2,370 bytes |
コンパイル時間 | 927 ms |
コンパイル使用メモリ | 126,440 KB |
実行使用メモリ | 28,528 KB |
最終ジャッジ日時 | 2024-06-22 00:46:41 |
合計ジャッジ時間 | 13,755 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 252 ms
13,908 KB |
testcase_01 | AC | 39 ms
6,944 KB |
testcase_02 | AC | 135 ms
13,096 KB |
testcase_03 | AC | 302 ms
14,464 KB |
testcase_04 | AC | 262 ms
13,988 KB |
testcase_05 | AC | 456 ms
14,620 KB |
testcase_06 | AC | 347 ms
13,608 KB |
testcase_07 | AC | 8 ms
6,940 KB |
testcase_08 | AC | 4 ms
6,944 KB |
testcase_09 | AC | 486 ms
17,904 KB |
testcase_10 | AC | 506 ms
16,768 KB |
testcase_11 | AC | 34 ms
14,424 KB |
testcase_12 | AC | 329 ms
18,684 KB |
testcase_13 | AC | 1 ms
6,940 KB |
testcase_14 | AC | 1 ms
6,940 KB |
testcase_15 | AC | 306 ms
14,324 KB |
testcase_16 | AC | 19 ms
6,944 KB |
testcase_17 | AC | 266 ms
14,448 KB |
testcase_18 | AC | 198 ms
13,956 KB |
testcase_19 | AC | 227 ms
14,556 KB |
testcase_20 | AC | 541 ms
17,004 KB |
testcase_21 | AC | 181 ms
13,864 KB |
testcase_22 | AC | 83 ms
6,940 KB |
testcase_23 | AC | 15 ms
6,940 KB |
testcase_24 | AC | 23 ms
6,944 KB |
testcase_25 | AC | 68 ms
12,944 KB |
testcase_26 | AC | 418 ms
15,764 KB |
testcase_27 | AC | 356 ms
14,512 KB |
testcase_28 | AC | 257 ms
14,412 KB |
testcase_29 | AC | 48 ms
6,944 KB |
testcase_30 | AC | 325 ms
14,328 KB |
testcase_31 | AC | 269 ms
13,816 KB |
testcase_32 | AC | 99 ms
13,124 KB |
testcase_33 | AC | 341 ms
17,016 KB |
testcase_34 | AC | 21 ms
6,944 KB |
testcase_35 | AC | 57 ms
6,940 KB |
testcase_36 | AC | 23 ms
6,940 KB |
testcase_37 | AC | 140 ms
13,472 KB |
testcase_38 | AC | 13 ms
7,208 KB |
testcase_39 | AC | 148 ms
13,980 KB |
testcase_40 | AC | 34 ms
6,940 KB |
testcase_41 | AC | 10 ms
6,948 KB |
testcase_42 | AC | 385 ms
13,628 KB |
testcase_43 | AC | 60 ms
8,688 KB |
testcase_44 | AC | 208 ms
13,532 KB |
testcase_45 | AC | 24 ms
6,944 KB |
testcase_46 | AC | 51 ms
8,288 KB |
testcase_47 | AC | 217 ms
12,972 KB |
testcase_48 | AC | 287 ms
14,224 KB |
testcase_49 | AC | 65 ms
6,944 KB |
testcase_50 | AC | 5 ms
6,944 KB |
testcase_51 | AC | 61 ms
6,940 KB |
testcase_52 | AC | 125 ms
14,860 KB |
testcase_53 | AC | 43 ms
6,948 KB |
testcase_54 | AC | 34 ms
6,944 KB |
testcase_55 | AC | 218 ms
13,680 KB |
testcase_56 | AC | 288 ms
13,772 KB |
testcase_57 | AC | 295 ms
14,000 KB |
testcase_58 | AC | 139 ms
14,112 KB |
testcase_59 | AC | 334 ms
28,528 KB |
testcase_60 | AC | 1 ms
6,940 KB |
testcase_61 | AC | 1 ms
6,940 KB |
testcase_62 | AC | 1 ms
6,940 KB |
ソースコード
import std.conv, std.functional, std.stdio, std.string; import std.algorithm, std.array, std.bigint, std.complex, std.container, std.math, std.numeric, std.range, 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)); } int N, M; int[] U, V; int Q; int[] A; void main() { try { for (; ; ) { N = readInt(); M = readInt(); U = new int[M]; V = new int[M]; foreach (i; 0 .. M) { U[i] = readInt() - 1; V[i] = readInt() - 1; } Q = readInt(); A = new int[Q]; foreach (q; 0 .. Q) { A[q] = readInt() - 1; } auto graph = new int[][N]; foreach (i; 0 .. M) { graph[U[i]] ~= V[i]; graph[V[i]] ~= U[i]; } foreach (q; 0 .. Q) { DList!int que; auto dist = new int[N]; dist[] = -1; dist[A[q]] = 0; que.insertBack(A[q]); for (; !que.empty; ) { const u = que.front; que.removeFront; foreach (v; graph[u]) { if (dist[v] == -1) { dist[v] = dist[u] + 1; que.insertBack(v); } } } int cnt, mx; foreach (u; 0 .. N) { if (dist[u] != -1) { ++cnt; chmax(mx, dist[u]); } } int ans; for (ans = 0; (1 << ans) < mx; ++ans) {} writeln(cnt - 1, " ", ans); } } } catch (EOFException e) { } }