結果
問題 | No.2888 Mamehinata |
ユーザー |
|
提出日時 | 2024-11-15 16:33:13 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 748 bytes |
コンパイル時間 | 404 ms |
コンパイル使用メモリ | 82,432 KB |
実行使用メモリ | 120,412 KB |
最終ジャッジ日時 | 2024-11-15 16:33:31 |
合計ジャッジ時間 | 14,826 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 3 |
other | AC * 7 WA * 45 |
ソースコード
from collections import dequeN, M = map(int,input().split())G = [list() for i in range(N+1)]for i in range(M):u, v = map(int,input().split())G[u].append(v)G[v].append(u)d = [-1]*(N+1)d[1] = 0dist = [0]*(N+1)dist[0] += 1Q = deque()Q.append(1)while len(Q) >= 1:x = Q.popleft()for nex in G[x]:if d[nex] == -1:d[nex] = d[x] + 1dist[d[nex]] += 1Q.append(nex)ans = [0]for i in range(1,N+1):if i % 2 == 1:if i == 1:ans.append(dist[i])else:ans.append(ans[i-2] + dist[i])else:if i == 2:if len(G[1]) == 0:ans.append(dist[i])else:ans.append(ans[i-2] + dist[i])else:ans.append(ans[i-2] + dist[i])for i in range(1,N+1):print(ans[i])