#pragma GCC optimize("Ofast,unroll-loops") #include #include #include #include using namespace std; #include using std::vector; template using vc = vector; template using vvc = vc>; template using vvvc = vc>; template using vvvvc = vc>; #define VC(T, a, ...) auto a = vector(__VA_ARGS__) #define VVC(T, a, n, ...) \ auto a = vector(n, vector(__VA_ARGS__)); #define VVVC(T, a, n, m, ...) \ auto a = vector(n, vector(m, vector(__VA_ARGS__))); #define VVVVC(T, a, n, m, l, ...) \ auto a = \ vector(n, vector(m, vector(l, vector(__VA_ARGS__)))); #define be begin() #define en end() #define all(a) (a).be, (a).en #define rbe rbegin() #define ren rend() #define allr(a) a.rbe, a.ren #include using std::sort; template void sort(A& a) { sort(all(a)); } #include using std::sort; template void sortr(A& a) { sort(allr(a)); } #include using std::reverse; template void reverse(A& a) { reverse(all(a)); } #define eval_0(a, ...) a #define eval_1(a, b, ...) b #define eval_2(a, b, c, ...) c #define eval_3(a, b, c, d, ...) d #define eval_4(a, b, c, d, e, ...) e #define eval_5(a, b, c, d, e, f, ...) f #define eval_6(a, b, c, d, e, f, g, ...) g #define iter_1(a, A) for (auto&& a : A) #define iter_2(a, b, A) for (auto&& [a, b] : A) #define iter_3(a, b, c, A) for (auto&& [a, b, c] : A) #define iter_4(a, b, c, d, A) for (auto&& [a, b, c, d] : A) #define iter_5(a, b, c, d, e, A) \ for (auto&& [a, b, c, d, e] : A) #define iter(...) \ eval_6(__VA_ARGS__, iter_5, iter_4, iter_3, iter_2, iter_1)( \ __VA_ARGS__ \ ) #define pb push_back #define eb emplace_back #define emp emplace #include using std::accumulate; template T sum(const vc& a) { return accumulate(all(a), T(0)); } #define loop while (1) using ll = long long; #define FOR_1(i, n) for (int i = 0; i < n; i++) #define FOR_2(i, a, b) for (ll i = a; i < b; i++) #define FOR_3(i, a, b, c) for (ll i = a; i < b; i += c) #define FOR(...) \ eval_4(__VA_ARGS__, FOR_3, FOR_2, FOR_1, rep)(__VA_ARGS__) #define FORR_1(i, n) for (int i = n; i-- > 0;) #define FORR_2(i, l, r) for (ll i = r; i-- > l;) #define FORR_3(i, l, r, d) for (ll i = r - 1; i >= l; i -= c) #define FORR(...) \ eval_4(__VA_ARGS__, FORR_3, FORR_2, FORR_1)(__VA_ARGS__) #define rep(t) for (int __ = 0; __ < t; ++__) template T binary_search(F f, T ok, T ng) { while (abs(ok - ng) > 1) { T x = (ok + ng) / 2; (f(x) ? ok : ng) = x; } return ok; } #include using std::lower_bound; using std::upper_bound; template auto lb(A& a, const T& x) { return lower_bound(all(a), x); } template int lbi(const A& a, const T& x) { return lb(a, x) - a.be; } template auto ub(A& a, const T& x) { return upper_bound(all(a), x); } template int ubi(const A& a, const T& x) { return ub(a, x) - a.be; } #include using std::string; using str = string; template int len(const A& a) { return a.size(); } #include using std::cout; #define yesno(y, n) \ void y(bool f = 1) { cout << (f ? #y : #n) << '\n'; } \ void n(bool f = 1) { y(!f); } yesno(yes, no); yesno(Yes, No); yesno(YES, NO); template vc iota(int n, T v=0) { vc a(n); iota(all(a), v); return a; } #include using std::pair; using pii = pair; #include using std::pair; using pll = pair; using vii = vc; using vll = vc; #define mt make_tuple #define ins insert template bool chmax(T& a, const U& b) { return b > a ? a = b, 1 : 0; } template bool chmin(T& a, const U& b) { return b < a ? a = b, 1 : 0; } using dbl = double; using ld = long double; #include using std::tuple; template using tup = tuple; #include using std::priority_queue; template using max_que = priority_queue; using std::greater; template using min_que = priority_queue, greater>; template T pop(min_que& q) { T v = q.top(); q.pop(); return v; } template T pop(max_que& q) { T v = q.top(); q.pop(); return v; } #include using std::max_element; using std::min_element; template auto max(const A& a) { return *max_element(all(a)); } template auto min(const A& a) { return *min_element(all(a)); } template T max(const set& s) { return *s.rbe; } template T min(const set& s) { return *s.be; } template T max(const multiset& s) { return *s.rbe; } template T min(const multiset& s) { return *s.be; } #include using namespace std; template constexpr auto min(T... a) { using U = common_type_t; return std::min(initializer_list{a...}); } template constexpr auto max(T... a) { using U = common_type_t; return std::max(initializer_list{a...}); } #define fi first #define se second #include using std::function; template using fn = function; template A fancy(const A& a, const vc& p) { int n = len(p); A b(n); FOR(i, n) b[i] = a[p[i]]; return b; } template vc argsort(const A& a) { auto p = iota(len(a)); sort(all(p), [&](int i, int j) { return a[i] == a[j] ? i < j : a[i] < a[j]; }); return p; } vc argperm(const vc& p) { int n = len(p); vc a(n); FOR(i, n) a[p[i]] = i; return a; } template vc rankify(const A& a) { return argperm(argsort(a)); } /* deprecated */ #include using std::queue; template T pop(queue& q) { T x = q.front(); q.pop(); return x; } #include using std::deque; template T pop_front(deque& q) { T x = q.front(); q.pop_front(); return x; } template T pop_back(deque& q) { T x = q.back(); q.pop_back(); return x; } template T pop(vc& a) { T x = a.back(); a.pop_back(); return x; } char pop(str& a) { char x = a.back(); a.pop_back(); return x; } class range { ll i, b, d; public: range(ll a, ll b, ll d): i(a), b(b), d(d) {} range(ll a, ll b): range(a, b, a < b ? 1 : -1) {} range(int n): range(0, n) {} range& begin() { return *this; } range& end() { return *this; } range& operator++() { i += d; return *this; } bool operator!=(const range&) const { return d > 0 && i < b || d < 0 && i > b; } ll operator*() const { return i; } }; template int signum(T x) { return x > 0 ? 1 : x < 0 ? -1 : 0; } template auto divmod(T n, U k) -> pair { T q = n / k; T r = n - q * k; if (signum(r) * signum(k) < 0) r += k, q--; return {q, r}; } #include using std::mt19937_64; using std::random_device; mt19937_64 mrand(random_device{}()); int rng(int x) { return mrand() % x; } constexpr double PI = 3.14159265358979323846; #include using namespace std; void fastio() { ios::sync_with_stdio(0); cin.tie(0); } #include #include using namespace std; void precise_float() { cout << setprecision(18); } template istream& operator>>(istream& i, pair& p) { return i >> p.fi >> p.se; } #include #include using namespace std; template void scan_tup(istream& i, T& x) { if constexpr (tuple_size::value > k) { i >> get(x); scan_tup(i, x); } } template istream& operator>>(istream& i, tuple& x) { scan_tup(i, x); return i; } template I& operator>>(I& i, vc& a) { iter(x, a) i >> x; return i; } #include using namespace std; template void scan(T&... a) { (cin >> ... >> a); } #define VEC(T, a, n) VC(T, a, n); cin >> a; #define V(T, a, n) VC(T, a, n); cin >> a; #define VV(T, a, n, m) VVC(T, a, n, m); cin >> a; #define VVV(T, a, n, m, l) VVC(T, a, n, m, l); cin >> a; #define INT(...) int __VA_ARGS__; scan(__VA_ARGS__) #define LL(...) ll __VA_ARGS__; scan(__VA_ARGS__) #define DBL(...) dbl __VA_ARGS__; scan(__VA_ARGS__) #define STR(...) str __VA_ARGS__; scan(__VA_ARGS__) #define VI(a, n) V(int, a, n) #define VL(a, n) V(ll, a, n) #define VII(a, n) V(pii, a, n) #define VLL(a, n) V(pll, a, n) #define VSTR(a, n) V(str, a, n) template ostream& operator<<(ostream& os, const array& a) { FOR(i, n) { if (i) os << ' '; os << a[i]; } return os; } template ostream& operator<<(ostream& os, array, n> a) { FOR(i, n) os << a[i] << '\n'; return os; } #include using namespace std; template ostream& operator<<(ostream& o, pair& p) { return o << p.fi << ' ' << p.se; } #include using namespace std; template void out_tup(ostream& o, T& x) { if constexpr (tuple_size::value > k) { if constexpr (k > 0) o << ' '; o << get(x); out_tup(o, x); } } template ostream& operator<<(ostream& o, tuple& x) { out_tup(o, x); return o; } template O& operator<<(O& o, vc a) { FOR(i, len(a)) { if (i) o << ' '; o << a[i]; } return o; } template O& operator<<(O& o, vvc a) { iter(x, a) o << x << '\n'; return o; } #include using namespace std; template void print(T a, U... b) { cout << a; ((cout << ' ' << b), ...); cout << '\n'; } vc bfs(const vvc& g, int s) { vc l(len(g), -1); l[s] = 0; vc q{s}; int i = 0; while (i < len(q)) { int u = q[i++]; iter(v, g[u]) { if (l[v] == -1) l[v] = l[u] + 1, q.pb(v); } } return l; } int main() { fastio(); int n, m; cin >> n >> m; vvc g(n); rep(m) { int u, v; cin >> u >> v; u--; v--; g[u].pb(v); g[v].pb(u); } auto l = bfs(g, 0); vc s(n + 1); iter(l, l) if(l != -1) s[l]++; FOR(i, n - 1) { s[i + 2] += s[i]; } FOR(i, 1, n + 1) { print(s[i]); } }