結果

問題 No.812 Change of Class
ユーザー KentarokumuraKentarokumura
提出日時 2019-04-12 22:20:43
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 741 bytes
コンパイル時間 439 ms
コンパイル使用メモリ 87,036 KB
実行使用メモリ 104,316 KB
最終ジャッジ日時 2023-09-03 13:12:22
合計ジャッジ時間 17,951 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 90 ms
85,928 KB
testcase_08 AC 85 ms
76,680 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 121 ms
102,420 KB
testcase_12 WA -
testcase_13 AC 82 ms
71,772 KB
testcase_14 AC 78 ms
71,636 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 102 ms
88,764 KB
testcase_39 WA -
testcase_40 WA -
testcase_41 AC 101 ms
87,672 KB
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 WA -
testcase_50 WA -
testcase_51 WA -
testcase_52 WA -
testcase_53 WA -
testcase_54 WA -
testcase_55 AC 201 ms
96,656 KB
testcase_56 AC 221 ms
100,764 KB
testcase_57 AC 231 ms
102,764 KB
testcase_58 AC 164 ms
88,988 KB
testcase_59 AC 246 ms
104,316 KB
testcase_60 AC 76 ms
71,784 KB
testcase_61 AC 78 ms
71,804 KB
testcase_62 AC 77 ms
71,800 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)//2
    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