結果

問題 No.812 Change of Class
ユーザー KentarokumuraKentarokumura
提出日時 2019-04-12 22:34:42
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 640 ms / 4,000 ms
コード長 774 bytes
コンパイル時間 452 ms
コンパイル使用メモリ 87,344 KB
実行使用メモリ 104,636 KB
最終ジャッジ日時 2023-09-03 13:34:58
合計ジャッジ時間 20,207 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 267 ms
96,624 KB
testcase_01 AC 141 ms
79,764 KB
testcase_02 AC 193 ms
86,888 KB
testcase_03 AC 289 ms
97,112 KB
testcase_04 AC 262 ms
96,576 KB
testcase_05 AC 635 ms
97,324 KB
testcase_06 AC 562 ms
94,096 KB
testcase_07 AC 105 ms
86,080 KB
testcase_08 AC 97 ms
76,976 KB
testcase_09 AC 640 ms
100,668 KB
testcase_10 AC 577 ms
99,252 KB
testcase_11 AC 132 ms
102,272 KB
testcase_12 AC 405 ms
99,216 KB
testcase_13 AC 88 ms
71,620 KB
testcase_14 AC 88 ms
71,736 KB
testcase_15 AC 473 ms
91,824 KB
testcase_16 AC 135 ms
78,760 KB
testcase_17 AC 377 ms
93,736 KB
testcase_18 AC 357 ms
89,776 KB
testcase_19 AC 380 ms
90,832 KB
testcase_20 AC 618 ms
98,916 KB
testcase_21 AC 317 ms
88,292 KB
testcase_22 AC 201 ms
85,288 KB
testcase_23 AC 130 ms
78,460 KB
testcase_24 AC 138 ms
79,056 KB
testcase_25 AC 185 ms
84,048 KB
testcase_26 AC 534 ms
95,044 KB
testcase_27 AC 541 ms
93,048 KB
testcase_28 AC 360 ms
91,172 KB
testcase_29 AC 173 ms
79,912 KB
testcase_30 AC 474 ms
93,100 KB
testcase_31 AC 386 ms
90,484 KB
testcase_32 AC 220 ms
84,900 KB
testcase_33 AC 463 ms
95,164 KB
testcase_34 AC 143 ms
78,908 KB
testcase_35 AC 179 ms
84,080 KB
testcase_36 AC 143 ms
78,904 KB
testcase_37 AC 274 ms
86,280 KB
testcase_38 AC 119 ms
89,088 KB
testcase_39 AC 261 ms
87,484 KB
testcase_40 AC 160 ms
79,412 KB
testcase_41 AC 114 ms
87,616 KB
testcase_42 AC 472 ms
92,452 KB
testcase_43 AC 175 ms
97,536 KB
testcase_44 AC 337 ms
88,468 KB
testcase_45 AC 138 ms
79,020 KB
testcase_46 AC 178 ms
97,176 KB
testcase_47 AC 333 ms
87,960 KB
testcase_48 AC 374 ms
91,088 KB
testcase_49 AC 166 ms
80,344 KB
testcase_50 AC 112 ms
77,352 KB
testcase_51 AC 183 ms
86,520 KB
testcase_52 AC 252 ms
93,796 KB
testcase_53 AC 158 ms
79,752 KB
testcase_54 AC 149 ms
79,436 KB
testcase_55 AC 237 ms
96,296 KB
testcase_56 AC 258 ms
101,048 KB
testcase_57 AC 269 ms
102,760 KB
testcase_58 AC 194 ms
89,180 KB
testcase_59 AC 287 ms
104,636 KB
testcase_60 AC 87 ms
71,940 KB
testcase_61 AC 87 ms
71,756 KB
testcase_62 AC 89 ms
71,688 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
from collections import deque
N,M=map(int,input().split())
table=[[] for i in range(N)]
for i in range(M):
    p,q=map(int,input().split())
    p,q=p-1,q-1
    table[p].append(q)
    table[q].append(p)
Q=int(input())
A=[int(input())-1 for i in range(Q)]

def check(x):
    #x=A[0]
    H=deque()
    H.append(x)
    visit=[-1]*N
    visit[x]=0
    while H:
        y=H.popleft()
        for t in table[y]:
            if visit[t]==-1:
                visit[t]=visit[y]+1
                H.append(t)
    day=(max(visit)-1).bit_length()
    #print(max(visit))
    if max(visit)<=1:
        day=0
    num=-1
    for i in range(N):
        if visit[i]!=-1:
            num+=1
    print(max(0,num),max(0,day))#,visit)
for a in A:
    check(a)
0