結果

問題 No.2888 Mamehinata
ユーザー atcoder8atcoder8
提出日時 2024-09-13 22:01:59
言語 Rust
(1.77.0)
結果
WA  
実行時間 -
コード長 896 bytes
コンパイル時間 14,581 ms
コンパイル使用メモリ 376,884 KB
実行使用メモリ 29,696 KB
最終ジャッジ日時 2024-09-13 22:03:16
合計ジャッジ時間 26,090 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 WA -
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 WA -
testcase_12 AC 1 ms
5,376 KB
testcase_13 AC 23 ms
9,472 KB
testcase_14 AC 127 ms
7,296 KB
testcase_15 WA -
testcase_16 AC 298 ms
22,016 KB
testcase_17 WA -
testcase_18 AC 56 ms
14,592 KB
testcase_19 AC 288 ms
23,680 KB
testcase_20 AC 232 ms
20,736 KB
testcase_21 AC 219 ms
20,224 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 338 ms
23,040 KB
testcase_25 AC 307 ms
18,432 KB
testcase_26 AC 354 ms
20,864 KB
testcase_27 AC 275 ms
12,672 KB
testcase_28 AC 47 ms
5,376 KB
testcase_29 AC 119 ms
10,496 KB
testcase_30 AC 317 ms
23,296 KB
testcase_31 AC 297 ms
19,840 KB
testcase_32 AC 179 ms
14,464 KB
testcase_33 AC 234 ms
18,432 KB
testcase_34 AC 198 ms
15,872 KB
testcase_35 AC 167 ms
13,952 KB
testcase_36 AC 375 ms
25,216 KB
testcase_37 AC 359 ms
25,984 KB
testcase_38 AC 94 ms
8,704 KB
testcase_39 AC 290 ms
21,248 KB
testcase_40 AC 387 ms
25,472 KB
testcase_41 AC 57 ms
6,144 KB
testcase_42 AC 302 ms
22,016 KB
testcase_43 AC 253 ms
23,808 KB
testcase_44 AC 289 ms
26,624 KB
testcase_45 AC 347 ms
29,696 KB
testcase_46 AC 41 ms
5,632 KB
testcase_47 AC 277 ms
25,728 KB
testcase_48 AC 184 ms
22,016 KB
testcase_49 AC 8 ms
6,144 KB
testcase_50 AC 24 ms
16,256 KB
testcase_51 AC 2 ms
5,376 KB
testcase_52 AC 1 ms
5,376 KB
testcase_53 AC 5 ms
5,376 KB
testcase_54 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

use std::collections::VecDeque;

use proconio::{input, marker::Usize1};

fn main() {
    input! {
        (n, m): (usize, usize),
        uv: [(Usize1, Usize1); m],
    }

    let mut graph = vec![vec![]; n];
    for &(u, v) in &uv {
        graph[u].push(v);
        graph[v].push(u);
    }

    let mut dists = vec![None; n];
    let mut queue = VecDeque::from([(0, 0)]);
    while let Some((cur, dist)) = queue.pop_front() {
        if dists[cur].is_some() {
            continue;
        }

        dists[cur] = Some(dist);

        queue.extend(graph[cur].iter().map(|&adj| (adj, dist + 1)));
    }

    let mut counts = vec![0_usize; n + 3];
    for &dist in &dists {
        if let Some(dist) = dist {
            counts[dist] += 1;
        }
    }

    for i in 2..=n + 2 {
        counts[i] += counts[i - 2];
    }

    for elem in &counts[1..=n] {
        println!("{}", elem);
    }
}
0