結果
| 問題 | No.812 Change of Class |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-05-22 20:56:13 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
AC
|
| 実行時間 | 635 ms / 4,000 ms |
| コード長 | 568 bytes |
| 記録 | |
| コンパイル時間 | 365 ms |
| コンパイル使用メモリ | 84,992 KB |
| 実行使用メモリ | 109,952 KB |
| 最終ジャッジ日時 | 2026-05-22 20:56:42 |
| 合計ジャッジ時間 | 16,002 ms |
|
ジャッジサーバーID (参考情報) |
judge3_1 / judge2_1 |
| 純コード判定待ち |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 60 |
ソースコード
from collections import deque
n,m=map(int,input().split())
v=[[] for i in range(n)]
for i in range(m):
a,b=map(int,input().split());a-=1;b-=1
v[a].append(b);v[b].append(a)
for i in range(int(input())):
a=int(input())-1
b=[-1]*n;b[a]=1
f=deque()
for j in v[a]:
f.append(j);b[j]=1
ans=0;c=0
while f:
q=f.popleft();c+=1
ans=max(ans,b[q])
for j in v[q]:
if b[j]==-1:
b[j]=b[q]+1
f.append(j)
d=0;f=1
while ans>f:
d+=1;f<<=1
ans=d
print(c,ans)