結果

問題 No.2888 Mamehinata
ユーザー loop0919loop0919
提出日時 2024-09-13 22:02:53
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 942 bytes
コンパイル時間 614 ms
コンパイル使用メモリ 82,260 KB
実行使用メモリ 135,496 KB
最終ジャッジ日時 2024-09-13 22:03:30
合計ジャッジ時間 15,971 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
54,520 KB
testcase_01 AC 42 ms
55,508 KB
testcase_02 AC 41 ms
53,940 KB
testcase_03 AC 43 ms
54,632 KB
testcase_04 WA -
testcase_05 AC 43 ms
56,148 KB
testcase_06 AC 43 ms
54,428 KB
testcase_07 AC 42 ms
54,132 KB
testcase_08 AC 42 ms
55,824 KB
testcase_09 AC 43 ms
55,308 KB
testcase_10 AC 41 ms
55,220 KB
testcase_11 WA -
testcase_12 AC 43 ms
55,304 KB
testcase_13 AC 166 ms
81,684 KB
testcase_14 AC 145 ms
91,676 KB
testcase_15 WA -
testcase_16 AC 382 ms
123,712 KB
testcase_17 WA -
testcase_18 AC 243 ms
85,236 KB
testcase_19 AC 458 ms
120,744 KB
testcase_20 AC 391 ms
112,180 KB
testcase_21 AC 408 ms
111,480 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 424 ms
128,568 KB
testcase_25 AC 320 ms
129,060 KB
testcase_26 AC 333 ms
127,340 KB
testcase_27 AC 210 ms
123,704 KB
testcase_28 AC 175 ms
83,448 KB
testcase_29 AC 230 ms
95,500 KB
testcase_30 AC 465 ms
125,740 KB
testcase_31 AC 422 ms
116,724 KB
testcase_32 AC 297 ms
106,020 KB
testcase_33 AC 373 ms
113,104 KB
testcase_34 AC 319 ms
107,712 KB
testcase_35 AC 314 ms
103,524 KB
testcase_36 AC 495 ms
124,572 KB
testcase_37 AC 541 ms
131,696 KB
testcase_38 AC 194 ms
90,520 KB
testcase_39 AC 407 ms
120,648 KB
testcase_40 AC 519 ms
130,156 KB
testcase_41 AC 154 ms
85,296 KB
testcase_42 AC 423 ms
123,008 KB
testcase_43 AC 324 ms
125,908 KB
testcase_44 AC 367 ms
125,104 KB
testcase_45 AC 378 ms
135,496 KB
testcase_46 AC 125 ms
82,672 KB
testcase_47 AC 332 ms
121,916 KB
testcase_48 AC 316 ms
111,204 KB
testcase_49 AC 101 ms
77,336 KB
testcase_50 AC 168 ms
85,512 KB
testcase_51 AC 80 ms
76,724 KB
testcase_52 AC 71 ms
73,156 KB
testcase_53 AC 88 ms
76,824 KB
testcase_54 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque
from itertools import accumulate

INF = float("inf")

N, M = map(int, input().split())
graph = [[] for _ in range(N)]

for _ in range(M):
    u, v = map(lambda x: int(x) - 1, input().split())
    graph[u].append(v)
    graph[v].append(u)

dist = [INF] * N
dist[0] = 0
que = deque([0])

while que:
    now_v = que.popleft()

    for next_v in graph[now_v]:
        if dist[next_v] != INF:
            continue
        dist[next_v] = dist[now_v] + 1
        que.append(next_v)

if dist.count(INF) == N - 1:
    for _ in range(N):
        print(0)

odd = [0] * (N + 1)
even = [0] * (N + 1)

for i in range(N):
    if dist[i] == INF:
        continue

    if dist[i] % 2 == 0:
        even[dist[i]] += 1
    else:
        odd[dist[i]] += 1

acc_odd = list(accumulate(odd))
acc_even = list(accumulate(even))

for i in range(1, N + 1):
    if i % 2 == 0:
        print(acc_even[i])
    else:
        print(acc_odd[i])
0