結果

問題 No.2888 Mamehinata
ユーザー atcoder8atcoder8
提出日時 2024-09-13 21:50:12
言語 Rust
(1.77.0)
結果
WA  
実行時間 -
コード長 989 bytes
コンパイル時間 16,925 ms
コンパイル使用メモリ 379,768 KB
実行使用メモリ 28,140 KB
最終ジャッジ日時 2024-09-13 21:51:08
合計ジャッジ時間 25,934 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 1 ms
6,812 KB
testcase_02 AC 1 ms
6,944 KB
testcase_03 AC 1 ms
6,940 KB
testcase_04 WA -
testcase_05 AC 1 ms
6,944 KB
testcase_06 AC 1 ms
6,944 KB
testcase_07 AC 2 ms
6,944 KB
testcase_08 AC 1 ms
6,940 KB
testcase_09 AC 1 ms
6,944 KB
testcase_10 AC 1 ms
6,940 KB
testcase_11 WA -
testcase_12 AC 1 ms
6,944 KB
testcase_13 AC 23 ms
9,600 KB
testcase_14 AC 123 ms
7,936 KB
testcase_15 WA -
testcase_16 AC 309 ms
20,748 KB
testcase_17 WA -
testcase_18 AC 56 ms
14,464 KB
testcase_19 AC 273 ms
22,400 KB
testcase_20 AC 228 ms
19,496 KB
testcase_21 AC 246 ms
19,152 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 320 ms
21,320 KB
testcase_25 AC 329 ms
19,868 KB
testcase_26 AC 305 ms
19,228 KB
testcase_27 AC 274 ms
14,272 KB
testcase_28 AC 47 ms
6,944 KB
testcase_29 AC 118 ms
9,856 KB
testcase_30 AC 303 ms
21,956 KB
testcase_31 AC 257 ms
18,632 KB
testcase_32 AC 170 ms
13,696 KB
testcase_33 AC 227 ms
17,388 KB
testcase_34 AC 190 ms
15,032 KB
testcase_35 AC 163 ms
13,184 KB
testcase_36 AC 359 ms
23,708 KB
testcase_37 AC 354 ms
24,432 KB
testcase_38 AC 95 ms
8,320 KB
testcase_39 AC 280 ms
19,968 KB
testcase_40 AC 371 ms
23,888 KB
testcase_41 AC 56 ms
5,888 KB
testcase_42 AC 290 ms
20,736 KB
testcase_43 AC 247 ms
22,756 KB
testcase_44 AC 279 ms
25,088 KB
testcase_45 AC 345 ms
28,140 KB
testcase_46 AC 41 ms
5,376 KB
testcase_47 AC 273 ms
24,448 KB
testcase_48 AC 175 ms
21,376 KB
testcase_49 AC 8 ms
6,016 KB
testcase_50 AC 25 ms
16,128 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; n];
    let mut queue = VecDeque::from([(0, 0)]);
    while let Some((cur, dist)) = queue.pop_front() {
        if dists[cur] != n {
            continue;
        }

        dists[cur] = dist;

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

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

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

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