結果

問題 No.812 Change of Class
ユーザー AEnAEn
提出日時 2022-11-20 23:38:20
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,156 ms / 4,000 ms
コード長 695 bytes
コンパイル時間 1,657 ms
コンパイル使用メモリ 81,340 KB
実行使用メモリ 104,368 KB
最終ジャッジ日時 2023-10-21 18:48:29
合計ジャッジ時間 24,784 ms
ジャッジサーバーID
(参考情報)
judge10 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 270 ms
92,328 KB
testcase_01 AC 117 ms
78,168 KB
testcase_02 AC 186 ms
86,260 KB
testcase_03 AC 306 ms
95,632 KB
testcase_04 AC 270 ms
92,828 KB
testcase_05 AC 1,156 ms
94,460 KB
testcase_06 AC 849 ms
91,272 KB
testcase_07 AC 55 ms
69,872 KB
testcase_08 AC 47 ms
63,372 KB
testcase_09 AC 1,003 ms
99,616 KB
testcase_10 AC 997 ms
97,920 KB
testcase_11 AC 120 ms
104,368 KB
testcase_12 AC 667 ms
99,048 KB
testcase_13 AC 41 ms
53,724 KB
testcase_14 AC 42 ms
53,712 KB
testcase_15 AC 685 ms
92,216 KB
testcase_16 AC 107 ms
77,212 KB
testcase_17 AC 488 ms
93,248 KB
testcase_18 AC 361 ms
89,996 KB
testcase_19 AC 438 ms
91,652 KB
testcase_20 AC 1,024 ms
97,112 KB
testcase_21 AC 376 ms
88,512 KB
testcase_22 AC 205 ms
84,676 KB
testcase_23 AC 113 ms
77,184 KB
testcase_24 AC 119 ms
77,352 KB
testcase_25 AC 174 ms
81,812 KB
testcase_26 AC 877 ms
94,672 KB
testcase_27 AC 722 ms
92,428 KB
testcase_28 AC 489 ms
90,960 KB
testcase_29 AC 150 ms
78,196 KB
testcase_30 AC 611 ms
91,676 KB
testcase_31 AC 402 ms
90,028 KB
testcase_32 AC 222 ms
85,348 KB
testcase_33 AC 549 ms
94,484 KB
testcase_34 AC 110 ms
77,308 KB
testcase_35 AC 160 ms
81,792 KB
testcase_36 AC 111 ms
77,412 KB
testcase_37 AC 273 ms
85,004 KB
testcase_38 AC 83 ms
85,388 KB
testcase_39 AC 273 ms
85,856 KB
testcase_40 AC 147 ms
78,164 KB
testcase_41 AC 81 ms
82,748 KB
testcase_42 AC 698 ms
91,508 KB
testcase_43 AC 178 ms
96,348 KB
testcase_44 AC 397 ms
87,392 KB
testcase_45 AC 119 ms
77,400 KB
testcase_46 AC 167 ms
95,496 KB
testcase_47 AC 482 ms
87,228 KB
testcase_48 AC 451 ms
92,092 KB
testcase_49 AC 164 ms
78,728 KB
testcase_50 AC 70 ms
72,584 KB
testcase_51 AC 162 ms
83,012 KB
testcase_52 AC 271 ms
91,672 KB
testcase_53 AC 136 ms
78,008 KB
testcase_54 AC 133 ms
77,924 KB
testcase_55 AC 237 ms
95,308 KB
testcase_56 AC 267 ms
99,260 KB
testcase_57 AC 274 ms
100,644 KB
testcase_58 AC 179 ms
87,980 KB
testcase_59 AC 297 ms
102,708 KB
testcase_60 AC 39 ms
55,580 KB
testcase_61 AC 40 ms
55,580 KB
testcase_62 AC 39 ms
55,580 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque

N, M = map(int,input().split())
G = [list() for _ in range(N)]
for i in range(M):
    p, q = map(int, input().split())
    p-=1;q-=1
    G[p].append(q)
    G[q].append(p)

Q = int(input())
for i in range(Q):
    A = int(input())
    d = deque()
    dis = [-1]*N
    dis[A-1] = 0
    d.append(A-1)
    while d:
        v = d.popleft()
        for nex in G[v]:
            if dis[nex]==-1:
                dis[nex] = dis[v]+1
                d.append(nex)
    m = max(dis)
    cnt = 0
    while m>1:
        if m%2==0:
            cnt += 1
            m //= 2
        else:
            cnt += 1
            m += 1
            m //= 2
    print(N-dis.count(-1)-1,cnt)
0