結果

問題 No.812 Change of Class
ユーザー brthyyjpbrthyyjp
提出日時 2022-02-09 16:00:26
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 978 ms / 4,000 ms
コード長 893 bytes
コンパイル時間 417 ms
コンパイル使用メモリ 87,228 KB
実行使用メモリ 105,468 KB
最終ジャッジ日時 2023-09-07 01:14:13
合計ジャッジ時間 26,448 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 288 ms
95,888 KB
testcase_01 AC 157 ms
79,836 KB
testcase_02 AC 222 ms
88,832 KB
testcase_03 AC 321 ms
99,156 KB
testcase_04 AC 295 ms
96,012 KB
testcase_05 AC 978 ms
99,064 KB
testcase_06 AC 634 ms
94,012 KB
testcase_07 AC 106 ms
86,184 KB
testcase_08 AC 99 ms
76,940 KB
testcase_09 AC 725 ms
101,336 KB
testcase_10 AC 784 ms
102,908 KB
testcase_11 AC 138 ms
102,228 KB
testcase_12 AC 516 ms
102,580 KB
testcase_13 AC 89 ms
71,496 KB
testcase_14 AC 89 ms
71,676 KB
testcase_15 AC 595 ms
93,600 KB
testcase_16 AC 154 ms
78,904 KB
testcase_17 AC 527 ms
94,392 KB
testcase_18 AC 370 ms
90,752 KB
testcase_19 AC 421 ms
92,816 KB
testcase_20 AC 873 ms
101,036 KB
testcase_21 AC 379 ms
90,132 KB
testcase_22 AC 236 ms
84,744 KB
testcase_23 AC 150 ms
78,904 KB
testcase_24 AC 150 ms
78,964 KB
testcase_25 AC 207 ms
84,476 KB
testcase_26 AC 667 ms
98,024 KB
testcase_27 AC 630 ms
94,612 KB
testcase_28 AC 448 ms
93,100 KB
testcase_29 AC 191 ms
79,676 KB
testcase_30 AC 472 ms
93,660 KB
testcase_31 AC 485 ms
91,780 KB
testcase_32 AC 256 ms
86,652 KB
testcase_33 AC 504 ms
96,424 KB
testcase_34 AC 149 ms
79,100 KB
testcase_35 AC 208 ms
85,100 KB
testcase_36 AC 152 ms
79,248 KB
testcase_37 AC 324 ms
86,928 KB
testcase_38 AC 122 ms
88,760 KB
testcase_39 AC 352 ms
86,932 KB
testcase_40 AC 167 ms
79,536 KB
testcase_41 AC 113 ms
87,180 KB
testcase_42 AC 551 ms
93,560 KB
testcase_43 AC 192 ms
96,380 KB
testcase_44 AC 461 ms
89,608 KB
testcase_45 AC 162 ms
79,044 KB
testcase_46 AC 180 ms
96,344 KB
testcase_47 AC 411 ms
91,032 KB
testcase_48 AC 424 ms
93,312 KB
testcase_49 AC 208 ms
80,460 KB
testcase_50 AC 116 ms
77,104 KB
testcase_51 AC 199 ms
86,296 KB
testcase_52 AC 272 ms
93,064 KB
testcase_53 AC 179 ms
79,756 KB
testcase_54 AC 171 ms
79,696 KB
testcase_55 AC 246 ms
95,860 KB
testcase_56 AC 274 ms
101,000 KB
testcase_57 AC 284 ms
104,288 KB
testcase_58 AC 200 ms
89,404 KB
testcase_59 AC 310 ms
105,468 KB
testcase_60 AC 92 ms
71,764 KB
testcase_61 AC 88 ms
71,772 KB
testcase_62 AC 89 ms
71,568 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
import io, os
input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline

from collections import deque
import bisect

N = 32
P = [0]*N
P[0] = 1
for i in range(1, N):
    P[i] = P[i-1]*2

n, m = map(int,input().split())
g = [[] for i in range(n)]
for i in range(m):
    x, y = map(int, input().split())
    x, y = x-1, y-1
    g[x].append(y)
    g[y].append(x)
q = int(input())
Q = []
for i in range(q):
    a = int(input())
    a -= 1
    Q.append(a)

for a in Q:
    q = deque([])
    q.append(a)
    dist = [-1]*n
    dist[a] = 0
    while q:
        v = q.popleft()
        for u in g[v]:
            if dist[u] != -1:
                continue
            dist[u] = dist[v]+1
            q.append(u)
    cnt = 0
    M = 0
    for i in range(n):
        if dist[i] != -1:
            cnt += 1
            M = max(M, dist[i])
    t = bisect.bisect_left(P, M)
    print(cnt-1, t)
0