結果

問題 No.2888 Mamehinata
ユーザー atcoder8atcoder8
提出日時 2024-09-13 21:57:12
言語 Rust
(1.77.0)
結果
WA  
実行時間 -
コード長 979 bytes
コンパイル時間 15,520 ms
コンパイル使用メモリ 378,796 KB
実行使用メモリ 29,664 KB
最終ジャッジ日時 2024-09-13 21:57:46
合計ジャッジ時間 26,737 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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,600 KB
testcase_14 AC 121 ms
7,424 KB
testcase_15 WA -
testcase_16 AC 282 ms
22,144 KB
testcase_17 WA -
testcase_18 AC 56 ms
14,592 KB
testcase_19 AC 278 ms
23,808 KB
testcase_20 AC 224 ms
20,608 KB
testcase_21 AC 227 ms
20,224 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 316 ms
22,864 KB
testcase_25 AC 295 ms
18,432 KB
testcase_26 AC 308 ms
20,864 KB
testcase_27 AC 267 ms
12,672 KB
testcase_28 AC 46 ms
5,376 KB
testcase_29 AC 115 ms
10,496 KB
testcase_30 AC 303 ms
23,296 KB
testcase_31 AC 245 ms
19,732 KB
testcase_32 AC 173 ms
14,464 KB
testcase_33 AC 237 ms
18,432 KB
testcase_34 AC 194 ms
15,872 KB
testcase_35 AC 162 ms
13,952 KB
testcase_36 AC 336 ms
25,216 KB
testcase_37 AC 341 ms
25,956 KB
testcase_38 AC 89 ms
8,576 KB
testcase_39 AC 273 ms
21,164 KB
testcase_40 AC 336 ms
25,344 KB
testcase_41 AC 57 ms
6,144 KB
testcase_42 AC 287 ms
21,932 KB
testcase_43 AC 278 ms
23,808 KB
testcase_44 AC 278 ms
26,496 KB
testcase_45 AC 324 ms
29,664 KB
testcase_46 AC 41 ms
5,632 KB
testcase_47 AC 272 ms
25,728 KB
testcase_48 AC 182 ms
22,272 KB
testcase_49 AC 9 ms
6,272 KB
testcase_50 AC 25 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 + 2];
    for &dist in &dists {
        if let Some(dist) = dist {
            counts[dist] += 1;
        }
    }

    for i in (0..n).step_by(2) {
        counts[i + 2] += counts[i];
    }
    for i in (1..n).step_by(2) {
        counts[i + 2] += counts[i];
    }

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