結果
問題 | No.812 Change of Class |
ユーザー | Coki628 |
提出日時 | 2020-08-18 18:57:22 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,412 ms / 4,000 ms |
コード長 | 1,484 bytes |
コンパイル時間 | 212 ms |
コンパイル使用メモリ | 83,040 KB |
実行使用メモリ | 126,604 KB |
最終ジャッジ日時 | 2024-10-12 03:07:37 |
合計ジャッジ時間 | 31,882 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 540 ms
105,472 KB |
testcase_01 | AC | 160 ms
79,488 KB |
testcase_02 | AC | 340 ms
90,368 KB |
testcase_03 | AC | 634 ms
114,560 KB |
testcase_04 | AC | 565 ms
107,764 KB |
testcase_05 | AC | 1,412 ms
110,336 KB |
testcase_06 | AC | 1,122 ms
100,992 KB |
testcase_07 | AC | 75 ms
70,912 KB |
testcase_08 | AC | 54 ms
64,384 KB |
testcase_09 | AC | 1,213 ms
107,520 KB |
testcase_10 | AC | 1,263 ms
108,512 KB |
testcase_11 | AC | 154 ms
105,344 KB |
testcase_12 | AC | 769 ms
101,108 KB |
testcase_13 | AC | 42 ms
54,784 KB |
testcase_14 | AC | 42 ms
54,656 KB |
testcase_15 | AC | 861 ms
97,024 KB |
testcase_16 | AC | 149 ms
79,264 KB |
testcase_17 | AC | 799 ms
97,920 KB |
testcase_18 | AC | 572 ms
91,776 KB |
testcase_19 | AC | 645 ms
93,832 KB |
testcase_20 | AC | 1,250 ms
109,184 KB |
testcase_21 | AC | 546 ms
91,000 KB |
testcase_22 | AC | 287 ms
83,712 KB |
testcase_23 | AC | 139 ms
79,104 KB |
testcase_24 | AC | 139 ms
78,080 KB |
testcase_25 | AC | 259 ms
82,816 KB |
testcase_26 | AC | 1,135 ms
125,696 KB |
testcase_27 | AC | 963 ms
99,060 KB |
testcase_28 | AC | 645 ms
93,696 KB |
testcase_29 | AC | 216 ms
80,076 KB |
testcase_30 | AC | 754 ms
97,280 KB |
testcase_31 | AC | 670 ms
93,440 KB |
testcase_32 | AC | 319 ms
84,864 KB |
testcase_33 | AC | 875 ms
100,144 KB |
testcase_34 | AC | 133 ms
78,592 KB |
testcase_35 | AC | 268 ms
83,120 KB |
testcase_36 | AC | 153 ms
79,028 KB |
testcase_37 | AC | 464 ms
87,936 KB |
testcase_38 | AC | 94 ms
81,152 KB |
testcase_39 | AC | 458 ms
87,040 KB |
testcase_40 | AC | 182 ms
78,848 KB |
testcase_41 | AC | 84 ms
77,696 KB |
testcase_42 | AC | 996 ms
100,096 KB |
testcase_43 | AC | 204 ms
92,056 KB |
testcase_44 | AC | 641 ms
91,940 KB |
testcase_45 | AC | 153 ms
78,264 KB |
testcase_46 | AC | 197 ms
94,848 KB |
testcase_47 | AC | 706 ms
93,440 KB |
testcase_48 | AC | 677 ms
93,952 KB |
testcase_49 | AC | 262 ms
80,768 KB |
testcase_50 | AC | 86 ms
77,056 KB |
testcase_51 | AC | 251 ms
84,992 KB |
testcase_52 | AC | 365 ms
94,464 KB |
testcase_53 | AC | 192 ms
79,488 KB |
testcase_54 | AC | 182 ms
79,860 KB |
testcase_55 | AC | 400 ms
103,680 KB |
testcase_56 | AC | 468 ms
112,896 KB |
testcase_57 | AC | 484 ms
114,024 KB |
testcase_58 | AC | 285 ms
91,392 KB |
testcase_59 | AC | 553 ms
126,604 KB |
testcase_60 | AC | 41 ms
54,400 KB |
testcase_61 | AC | 40 ms
54,272 KB |
testcase_62 | AC | 40 ms
54,528 KB |
ソースコード
import sys from math import log2 def input(): return sys.stdin.readline().strip() def list2d(a, b, c): return [[c] * b for i in range(a)] def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)] def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)] def ceil(x, y=1): return int(-(-x // y)) def INT(): return int(input()) def MAP(): return map(int, input().split()) def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)] def Yes(): print('Yes') def No(): print('No') def YES(): print('YES') def NO(): print('NO') sys.setrecursionlimit(10 ** 9) INF = 10 ** 19 MOD = 10 ** 9 + 7 EPS = 10 ** -10 def bfs(nodes, src): """ BFS(一般グラフ、重みなし) """ from collections import deque N = len(nodes) que = deque([src]) dist = [INF] * N dist[src] = 0 cnt = 0 while que: u = que.popleft() for v in nodes[u]: if dist[v] != INF: continue dist[v] = dist[u] + 1 que.append(v) cnt += 1 mx = 0 for i in range(N): if dist[i] != INF and dist[i] >= 2: mx = max(mx, ceil(log2(dist[i]))) return cnt, mx N, M = MAP() nodes = [[] for i in range(N)] for i in range(M): a, b = MAP() a -= 1; b -= 1 nodes[a].append(b) nodes[b].append(a) Q = INT() for _ in range(Q): x = INT() x -= 1 cnt, mx = bfs(nodes, x) print(cnt, mx)