結果

問題 No.2888 Mamehinata
ユーザー miya256
提出日時 2024-09-14 02:43:13
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
MLE  
実行時間 -
コード長 492 bytes
コンパイル時間 86 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 824,860 KB
最終ジャッジ日時 2024-09-14 02:43:18
合計ジャッジ時間 4,482 ms
ジャッジサーバーID
(参考情報)
judge5 / judge6
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other MLE * 1 -- * 51
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque

def bfs(v):
    dq = deque([(v,0)])
    while dq:
        v,d = dq.popleft()
        if d > n:
            return
        if v not in cnt[d-1]:
            cnt[d].add(v)
        for nv in g[v]:
            dq.append((nv,d+1))

n,m = map(int,input().split())
g = [[] for _ in range(n)]
for _ in range(m):
    u,v = map(int,input().split())
    g[u-1].append(v-1)
    g[v-1].append(u-1)
cnt = [set() for _ in range(n+1)]
bfs(0)
for i in cnt[1:]:
    print(len(i))
0