結果
問題 | No.812 Change of Class |
ユーザー |
![]() |
提出日時 | 2019-04-12 22:10:59 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 692 bytes |
コンパイル時間 | 424 ms |
コンパイル使用メモリ | 82,292 KB |
実行使用メモリ | 108,776 KB |
最終ジャッジ日時 | 2024-06-12 18:37:52 |
合計ジャッジ時間 | 16,981 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 WA * 1 |
other | AC * 10 WA * 50 |
ソースコード
import sysinput = sys.stdin.readlinefrom collections import dequeN,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-1table[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]*Nvisit[x]=0while H:y=H.popleft()for t in table[y]:if visit[t]==-1:visit[t]=visit[y]+1H.append(t)day=max(visit)-1num=-1for i in range(N):if visit[i]!=-1:num+=1print(max(0,num),max(0,day))for a in A:check(a)