結果

問題 No.2888 Mamehinata
ユーザー FplusFplusF
提出日時 2024-09-13 22:03:31
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 2,016 bytes
コンパイル時間 3,094 ms
コンパイル使用メモリ 256,940 KB
実行使用メモリ 19,824 KB
最終ジャッジ日時 2024-09-13 22:03:45
合計ジャッジ時間 10,927 ms
ジャッジサーバーID
(参考情報)
judge6 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 47 WA * 4 TLE * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ull=unsigned long long;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll,ll>;
using ld=long double;
const ll INF=(1ll<<60);
#define rep(i,n) for (ll i=0;i<(ll)(n);i++)
#define replr(i,l,r) for (ll i=(ll)(l);i<(ll)(r);i++)
#define all(v) v.begin(),v.end()
#define len(v) ((ll)v.size())
template<class T> inline bool chmin(T &a,T b){
    if(a>b){
        a=b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T &a,T b){
    if(a<b){
        a=b;
        return true;
    }
    return false;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n,m;
    cin >> n >> m;
    vector<vector<ll>> g(n);
    while(m--){
        ll u,v;
        cin >> u >> v;
        u--;
        v--;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    if(n*(n+m)<=1e8){
        vector<ll> c(n,0);
        c[0]=1;
        vector<ll> ans;
        rep(_,n){
            rep(i,n){
                if(c[i]==1) continue;
                for(auto j:g[i]){
                    if(c[j]==1) c[i]=2;
                }
            }
            rep(i,n){
                if(c[i]==1) c[i]=0;
            }
            ll now=0;
            rep(i,n){
                if(c[i]==2) c[i]=1;
                if(c[i]==1) now++;
            }
            ans.push_back(now);
        }
        ll x=ans[98],y=ans[99];
        while(len(ans)<n){
            ans.push_back(x);
            ans.push_back(y);
        }
        rep(i,n) cout << ans[i] << '\n';
        return 0;
    }
    queue<ll> q;
    vector<ll> ans;
    vector<ll> d(n,-1),cnt(n+1,0);
    q.push(0);
    d[0]=0;
    cnt[0]=1;
    while(!q.empty()){
        ll x=q.front();
        q.pop();
        for(auto i:g[x]){
            if(d[i]!=-1) continue;
            d[i]=d[x]+1;
            cnt[d[i]]++;
            q.push(i);
        }
    }
    vector<ll> c(2,0);
    c[0]=1;
    replr(i,1,n+1){
        c[i&1]+=cnt[i];
        cout << c[i&1] << '\n';
    }
}
0