結果

問題 No.2888 Mamehinata
ユーザー maeshunmaeshun
提出日時 2024-09-14 11:45:36
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 478 ms / 2,000 ms
コード長 1,446 bytes
コンパイル時間 5,006 ms
コンパイル使用メモリ 265,532 KB
実行使用メモリ 16,728 KB
最終ジャッジ日時 2024-09-14 11:45:57
合計ジャッジ時間 20,143 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 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 AC 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 57 ms
5,376 KB
testcase_14 AC 201 ms
7,296 KB
testcase_15 AC 329 ms
10,496 KB
testcase_16 AC 384 ms
13,116 KB
testcase_17 AC 205 ms
8,704 KB
testcase_18 AC 118 ms
6,016 KB
testcase_19 AC 397 ms
13,032 KB
testcase_20 AC 324 ms
11,520 KB
testcase_21 AC 313 ms
11,136 KB
testcase_22 AC 259 ms
10,544 KB
testcase_23 AC 363 ms
12,952 KB
testcase_24 AC 422 ms
14,336 KB
testcase_25 AC 386 ms
13,952 KB
testcase_26 AC 392 ms
13,696 KB
testcase_27 AC 311 ms
11,732 KB
testcase_28 AC 61 ms
5,376 KB
testcase_29 AC 161 ms
7,680 KB
testcase_30 AC 420 ms
14,236 KB
testcase_31 AC 348 ms
12,416 KB
testcase_32 AC 237 ms
9,728 KB
testcase_33 AC 319 ms
11,776 KB
testcase_34 AC 267 ms
10,624 KB
testcase_35 AC 222 ms
9,472 KB
testcase_36 AC 461 ms
15,196 KB
testcase_37 AC 478 ms
15,616 KB
testcase_38 AC 128 ms
6,912 KB
testcase_39 AC 388 ms
13,152 KB
testcase_40 AC 476 ms
15,280 KB
testcase_41 AC 76 ms
5,376 KB
testcase_42 AC 400 ms
13,568 KB
testcase_43 AC 326 ms
13,876 KB
testcase_44 AC 367 ms
15,196 KB
testcase_45 AC 414 ms
16,728 KB
testcase_46 AC 54 ms
5,376 KB
testcase_47 AC 352 ms
14,832 KB
testcase_48 AC 263 ms
10,688 KB
testcase_49 AC 23 ms
5,376 KB
testcase_50 AC 75 ms
6,016 KB
testcase_51 AC 4 ms
5,376 KB
testcase_52 AC 3 ms
5,376 KB
testcase_53 AC 12 ms
5,376 KB
testcase_54 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define rep(i, n) for(int i=0;i<(n);++i)
#define rep1(i, n) for(int i=1;i<=(n);i++)
#define ll long long
using mint = modint998244353;
using P = pair<ll,ll>;
using lb = long double;
using T = tuple<ll, ll, ll>;
#ifdef LOCAL
#  include <debug_print.hpp>
#  define dbg(...) debug_print::multi_print(#__VA_ARGS__, __VA_ARGS__)
#else
#  define dbg(...) (static_cast<void>(0))
#endif

int main()
{
    int n,m;
    cin >> n >> m;
    vector<vector<int>> g(n);
    rep(i,m){
        int u, v;
        cin >> u >> v;
        --u;--v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    vector<int> dist(n, 1e9);
    queue<int> q;
    dist[0] = 0;
    q.push(0);
    while(!q.empty()) {
        int u = q.front();q.pop();
        for(int v : g[u]) {
            if(dist[v]==1e9) {
                dist[v] = dist[u] + 1;
                q.push(v);
            }
        }
    }
    int even = 1;
    int odd = 0;
    vector<int> d(n+2);
    rep(i,n) {
        if(dist[i]==1e9) continue;
        d[dist[i]]++;
    }
    dbg(d);
    if(g[0].size()==0) {
        rep(i,n) {
            cout << 0 << endl;
        }
        return 0;
    }
    rep(i,n) {
        if(i%2==0) {
            odd += d[i+1];
            cout << odd << endl;
        }
        else{
            even += d[i+1];
            cout << even << endl;
        }
    }
    return 0;
}
0