結果

問題 No.2888 Mamehinata
ユーザー atcoder8atcoder8
提出日時 2024-09-13 21:53:53
言語 Rust
(1.77.0)
結果
WA  
実行時間 -
コード長 964 bytes
コンパイル時間 15,133 ms
コンパイル使用メモリ 380,236 KB
実行使用メモリ 28,160 KB
最終ジャッジ日時 2024-09-13 21:54:32
合計ジャッジ時間 26,385 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 2 ms
5,248 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 WA -
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 3 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 WA -
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 78 ms
9,472 KB
testcase_14 AC 166 ms
8,064 KB
testcase_15 WA -
testcase_16 AC 294 ms
20,736 KB
testcase_17 WA -
testcase_18 AC 70 ms
14,464 KB
testcase_19 AC 315 ms
22,400 KB
testcase_20 AC 257 ms
19,712 KB
testcase_21 AC 232 ms
19,200 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 377 ms
21,376 KB
testcase_25 AC 329 ms
19,968 KB
testcase_26 AC 318 ms
19,200 KB
testcase_27 AC 282 ms
14,208 KB
testcase_28 AC 51 ms
5,376 KB
testcase_29 AC 186 ms
9,984 KB
testcase_30 AC 318 ms
21,888 KB
testcase_31 AC 255 ms
18,560 KB
testcase_32 AC 174 ms
13,696 KB
testcase_33 AC 237 ms
17,408 KB
testcase_34 AC 193 ms
14,848 KB
testcase_35 AC 162 ms
13,184 KB
testcase_36 AC 336 ms
23,936 KB
testcase_37 AC 437 ms
24,320 KB
testcase_38 AC 93 ms
8,448 KB
testcase_39 AC 286 ms
19,968 KB
testcase_40 AC 343 ms
23,936 KB
testcase_41 AC 57 ms
5,632 KB
testcase_42 AC 285 ms
20,736 KB
testcase_43 AC 246 ms
22,656 KB
testcase_44 AC 311 ms
25,088 KB
testcase_45 AC 321 ms
28,160 KB
testcase_46 AC 40 ms
5,376 KB
testcase_47 AC 270 ms
24,448 KB
testcase_48 AC 177 ms
21,376 KB
testcase_49 AC 8 ms
5,888 KB
testcase_50 AC 24 ms
16,256 KB
testcase_51 AC 2 ms
5,376 KB
testcase_52 AC 2 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![n + 1; n];
    let mut queue = VecDeque::from([(0, 0)]);
    while let Some((cur, dist)) = queue.pop_front() {
        if dists[cur] != n + 1 {
            continue;
        }

        dists[cur] = dist;

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

    let mut counts = vec![0_usize; n + 2];
    for &dist in &dists {
        if dist < n + 1 {
            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