結果

問題 No.2888 Mamehinata
ユーザー n0ma_run0ma_ru
提出日時 2024-09-13 21:31:41
言語 C++17(gcc12)
(gcc 12.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,293 bytes
コンパイル時間 3,071 ms
コンパイル使用メモリ 209,604 KB
実行使用メモリ 16,732 KB
最終ジャッジ日時 2024-09-13 21:32:14
合計ジャッジ時間 9,805 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 45 WA * 7
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define ALL(v) v.begin(),v.end()
#define dbg(x) cerr << #x << ": " << (x) << endl;
template<class F, class S>
ostream& operator<<(ostream& os, pair<F,S>& p) {
    os << '(' << p.first << ',' << p.second << ')';
    return os;
}
template<class Iter>
void print(Iter beg, Iter end) {
    for (Iter itr = beg; itr != end; ++itr) {
        cerr << *itr << ' ';
    }
    cerr << '\n';
}
int N,M;
vector<vector<int>> G;
int main() {
    cin >> N >> M;
    G.resize(N);
    for (int i = 0; i < M; ++i) {
        int a,b; cin >> a >> b;
        --a; --b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    vector<int> dis(N,1e9);
    queue<int> q;
    dis[0] = 0;
    q.push(0);
    while (q.size()) {
        int pos = q.front(); q.pop();
        for (int to : G[pos]) {
            if (dis[to] > dis[pos] + 1) {
                dis[to] = dis[pos] + 1;
                q.push(to);
            }
        }
    }
    // print(ALL(dis));
    vector<int> cnt(N+1);
    for (int i = 0; i < N; ++i) {
        if (dis[i] == 1e9) continue;
        cnt[dis[i]]++;
    }
    int even=1, odd=0;
    for (int i = 1; i <= N; ++i) {
        (i % 2 == 0 ? even : odd) += cnt[i];
        cout << (i%2==0 ? even : odd) << '\n';
    }
}
0