#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define allof(obj) (obj).begin(), (obj).end() #define range(i, l, r) for(int i=l;i>1)|y_bit)) #define bit_kth(i, k) ((i >> k)&1) #define bit_highest(i) (i?63-__builtin_clzll(i):-1) #define bit_lowest(i) (i?__builtin_ctzll(i):-1) #define sleepms(t) std::this_thread::sleep_for(std::chrono::milliseconds(t)) using ll = long long; using ld = long double; using ul = uint64_t; using pi = std::pair; using pl = std::pair; using namespace std; template std::ostream &operator << (std::ostream &dest, const std::pair &p) { dest << p.first << ' ' << p.second; return dest; } template std::ostream &operator << (std::ostream &dest, const std::tuple &t) { dest << std::get<0>(t) << ' ' << std::get<1>(t); return dest; } template std::ostream &operator << (std::ostream &dest, const std::tuple &t) { dest << std::get<0>(t) << ' ' << std::get<1>(t) << ' ' << std::get<2>(t); return dest; } template std::ostream &operator << (std::ostream &dest, const std::tuple &t) { dest << std::get<0>(t) << ' ' << std::get<1>(t) << ' ' << std::get<2>(t) << ' ' << std::get<3>(t); return dest; } template std::ostream &operator << (std::ostream &dest, const std::vector> &v) { int sz = v.size(); if (!sz) return dest; for (int i = 0; i < sz; i++) { int m = v[i].size(); for (int j = 0; j < m; j++) dest << v[i][j] << (i != sz - 1 && j == m - 1 ? '\n' : ' '); } return dest; } template std::ostream &operator << (std::ostream &dest, const std::vector &v) { int sz = v.size(); if (!sz) return dest; for (int i = 0; i < sz - 1; i++) dest << v[i] << ' '; dest << v[sz - 1]; return dest; } template std::ostream &operator << (std::ostream &dest, const std::array &v) { if (!sz) return dest; for (int i = 0; i < sz - 1; i++) dest << v[i] << ' '; dest << v[sz - 1]; return dest; } template std::ostream &operator << (std::ostream &dest, const std::set &v) { for (auto itr = v.begin(); itr != v.end();) { dest << *itr; itr++; if (itr != v.end()) dest << ' '; } return dest; } template std::ostream &operator << (std::ostream &dest, const std::map &v) { for (auto itr = v.begin(); itr != v.end(); ) { dest << '(' << itr->first << ", " << itr->second << ')'; itr++; if (itr != v.end()) dest << '\n'; } return dest; } template vector make_vec(size_t sz, T val) { return std::vector(sz, val); } template auto make_vec(size_t sz, Tail ...tail) { return std::vector(tail...))>(sz, make_vec(tail...)); } template vector read_vec(size_t sz) { std::vector v(sz); for (int i = 0; i < (int)sz; i++) std::cin >> v[i]; return v; } template auto read_vec(size_t sz, Tail ...tail) { auto v = std::vector(tail...))>(sz); for (int i = 0; i < (int)sz; i++) v[i] = read_vec(tail...); return v; } // x / y以上の最小の整数 ll ceil_div(ll x, ll y) { assert(y > 0); return (x + (x > 0 ? y - 1 : 0)) / y; } // x / y以下の最大の整数 ll floor_div(ll x, ll y) { assert(y > 0); return (x + (x > 0 ? 0 : -y + 1)) / y; } void io_init() { std::cin.tie(nullptr); std::ios::sync_with_stdio(false); } template struct csr { std::vector start; std::vector elist; csr() {} explicit csr(int n, const std::vector>& edges) : start(n + 1), elist(edges.size()) { for (auto e : edges) { start[e.first + 1]++; } for (int i = 1; i <= n; i++) { start[i] += start[i - 1]; } auto counter = start; for (auto e : edges) { elist[counter[e.first]++] = e.second; } } ~csr() {} int N() const { return start.size() - 1; } int deg(int i) const { return start[i + 1] - start[i]; } int begin(int i) const { return start[i]; } int end(int i) const { return start[i + 1]; } E& operator [] (int i) { return elist[i]; } }; // O((V + E)logV) // 辺の重みが非負(負の閉路がなければ一応動く) template struct dijkstra { private: int _s; csr &G; public: static constexpr W inf = std::numeric_limits::max() / 2; dijkstra() {} dijkstra(csr &G) : G(G) {} std::vector dist; std::vector par; // targetを指定した場合targetに到達した時点で打ち切る void build(int s, int target = -1) { _s = s; using P = std::pair; int N = G.N(); if (dist.empty()) { dist.resize(N, inf); par.resize(N, -1); } else { std::fill(dist.begin(), dist.end(), inf); std::fill(par.begin(), par.end(), -1); } std::priority_queue, std::greater

> que; dist[s] = 0; que.push({0, s}); while (!que.empty()) { auto [w, v] = que.top(); if (v == target) break; que.pop(); if (dist[v] < w) continue; for (int i = G.begin(v); i < G.end(v); i++) { int to = G.elist[i]; W d = dist[v] + G.elist[i].weight(); if (dist[to] > d) { dist[to] = d; par[to] = v; que.push(P{d, to}); } } } } // 到達不可能な場合空 std::vector path(int t) { assert(!dist.empty()); if (par[t] == -1) return {}; std::vector res{t}; while (t != _s) { t = par[t]; res.push_back(t); } std::reverse(res.begin(), res.end()); return res; } W operator [](int v) const { return dist[v]; } }; template struct edge_base { using W = _W; int t; edge_base() {} edge_base(int _t) : t(_t) {} virtual int from() const { assert(false); } int to() const { return t; } virtual W weight() const { assert(false); } operator int() const { return t; } }; struct simple_edge : edge_base { simple_edge() {} simple_edge(int _t) : edge_base(_t) {} int weight() const override { return 1; } }; template struct weighted_edge : edge_base<_W> { using W = _W; W w; weighted_edge() {} weighted_edge(int _t, _W _w) : edge_base<_W>(_t), w(_w) {} W weight() const override { return w; } }; int main() { io_init(); int N, M; std::cin >> N >> M; using edge = simple_edge; std::vector> E; for (int i = 0; i < M; i++) { int a, b; std::cin >> a >> b; a--, b--; E.push_back({a, {b}}); E.push_back({b, {a}}); } csr G(N, E); if (G.begin(0) == G.end(0)) { for (int i = 0; i < N; i++) { std::cout << 0 << '\n'; } return 0; } dijkstra D(G); D.build(0); auto d = D.dist; sort(allof(d)); int j = 0, e = 0, o = 0; for (int t = 1; t <= N; t++) { while (j < N && d[j] <= t) { if (d[j] % 2 == 0) e++; else o++; j++; } if (t & 1) { std::cout << o << '\n'; } else { std::cout << e << '\n'; } } }