結果
問題 |
No.812 Change of Class
|
ユーザー |
![]() |
提出日時 | 2019-04-13 01:24:01 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 726 bytes |
コンパイル時間 | 262 ms |
コンパイル使用メモリ | 12,800 KB |
実行使用メモリ | 42,820 KB |
最終ジャッジ日時 | 2024-06-12 20:19:30 |
合計ジャッジ時間 | 76,634 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 12 WA * 48 |
ソースコード
n,m=map(int, input().split()) pq = [list(map(int, input().split())) for i in range(m)] Q=int(input()) a = [int(input()) for i in range(Q)] b=[[] for i in range(n+1)] for i in pq: p=i[0] q=i[1] b[p].append(q) b[q].append(p) for i in a: if(b[i]==[]): print(0,0) continue que=[i] check=[0 for i in range(n+1)] check[i]=1 fri=0 dif=-1 while len(que)>0: tmpl=que.copy() que=[] for j in tmpl: for k in b[j]: if(check[k]==0): que.append(k) check[k]=1 fri+=1 dif+=1 if(dif==1): day=0 else: day=-(-dif//2) print(fri,day)