#![allow(non_snake_case)] #[allow(unused_imports)] use proconio::{fastout, input, marker::*}; #[fastout] fn main() { input! { N: usize, M: usize, edges: [(Usize1, Usize1); M], } let dist = { let mut graph = vec![vec![]; N]; for (u, v) in edges { graph[u].push(v); graph[v].push(u); } let mut seen = vec![false; N]; let mut dist = vec![usize::MAX; N]; let mut q = std::collections::VecDeque::new(); q.push_back(0); seen[0] = true; dist[0] = 0; while let Some(u) = q.pop_front() { for &v in graph[u].iter() { if seen[v] { continue; } q.push_back(v); seen[v] = true; dist[v] = dist[u] + 1; } } dist }; let mut cnt = vec![0u32; N + 1]; for i in 0..N { if dist[i] == usize::MAX { continue; } cnt[dist[i]] += 1; } for i in 0..=N - 2 { cnt[i + 2] += cnt[i]; } println!( "{}", cnt[1..] .iter() .map(|x| x.to_string()) .collect::>() .join("\n") ); }