結果

問題 No.2888 Mamehinata
コンテスト
ユーザー 👑 ONPU3
提出日時 2026-10-28 14:34:01
言語 C++23
(gcc 15.3.0 + boost 1.92.0 + ACL)
コンパイル:
g++-15 -O2 -fplugin=/usr/lib/yukicoder/noavx512-gcc15.so -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 770 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 3,123 ms
コンパイル使用メモリ 341,704 KB
実行使用メモリ 19,844 KB
最終ジャッジ日時 2026-10-28 14:34:56
合計ジャッジ時間 21,841 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge7_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 45 WA * 7
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main()
{
    cin.tie(0)->sync_with_stdio(0);
    ll n,m;cin>>n>>m;
    vector<vector<ll>>g(n);
    for(int i=0;i<m;i++)
    {
        ll u,v;cin>>u>>v;
        u--;v--;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    queue<ll>que;
    vector<ll>dist(n+1,-1),cnt(n+1),ans(2);
    que.push(0);
    dist[0]=0;
    cnt[0]=1;
    while(!que.empty())
    {
        ll now=que.front();
        que.pop();
        for(ll nex:g[now])
        {
            if(dist[nex]!=-1)continue;
            dist[nex]=dist[now]+1;
            cnt[dist[nex]]++;
            que.push(nex);
        }
    }
    for(int i=0;i<=n;i++)
    {
        ans[i%2]+=cnt[i];
        if(i!=0)cout<<ans[i%2]<<endl;
    }
}
0