結果

問題 No.2888 Mamehinata
ユーザー miya256
提出日時 2024-09-14 02:50:23
言語 PyPy3
(7.3.15)
結果
MLE  
実行時間 -
コード長 607 bytes
コンパイル時間 308 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 857,884 KB
最終ジャッジ日時 2024-09-14 02:50:29
合計ジャッジ時間 5,395 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other MLE * 1 -- * 51
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque

def bfs(v):
    dq = deque([(v,0)])
    now_d = 1
    cnt0 = set()
    cnt1 = set()
    cnt0.add(v)
    while dq:
        v,d = dq.popleft()
        if d > now_d:
            print(len(cnt1))
            cnt0 = set(cnt1)
            cnt1 = set()
            now_d = d
        if d > n:
            return
        if v not in cnt0:
            cnt1.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)
bfs(0)
0