結果
問題 |
No.2888 Mamehinata
|
ユーザー |
|
提出日時 | 2024-11-15 16:31:50 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 755 bytes |
コンパイル時間 | 669 ms |
コンパイル使用メモリ | 82,180 KB |
実行使用メモリ | 120,276 KB |
最終ジャッジ日時 | 2024-11-15 16:32:06 |
合計ジャッジ時間 | 15,399 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 3 |
other | AC * 7 WA * 45 |
ソースコード
from collections import deque N, 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] = 0 dist = [0]*(N+1) dist[0] += 1 Q = deque() Q.append(1) while len(Q) >= 1: x = Q.popleft() for nex in G[x]: if d[nex] == -1: d[nex] = d[x] + 1 dist[d[nex]] += 1 Q.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: print( ans.append(dist[i] + dist[i])) else: ans.append(ans[i-2] + dist[i]) for i in range(1,N+1): print(ans[i])