結果

問題 No.2888 Mamehinata
ユーザー makichanmakichan
提出日時 2024-09-13 21:34:38
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 234 ms / 2,000 ms
コード長 1,061 bytes
コンパイル時間 5,832 ms
コンパイル使用メモリ 312,016 KB
実行使用メモリ 16,860 KB
最終ジャッジ日時 2024-09-13 21:34:56
合計ジャッジ時間 13,555 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,248 KB
testcase_02 AC 2 ms
5,248 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 3 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 52 ms
5,376 KB
testcase_14 AC 34 ms
7,424 KB
testcase_15 AC 153 ms
9,620 KB
testcase_16 AC 167 ms
13,240 KB
testcase_17 AC 31 ms
7,552 KB
testcase_18 AC 94 ms
6,144 KB
testcase_19 AC 206 ms
12,972 KB
testcase_20 AC 160 ms
11,392 KB
testcase_21 AC 160 ms
11,008 KB
testcase_22 AC 62 ms
9,312 KB
testcase_23 AC 92 ms
11,272 KB
testcase_24 AC 172 ms
14,220 KB
testcase_25 AC 135 ms
13,952 KB
testcase_26 AC 130 ms
13,724 KB
testcase_27 AC 62 ms
11,776 KB
testcase_28 AC 26 ms
5,376 KB
testcase_29 AC 70 ms
7,808 KB
testcase_30 AC 195 ms
14,208 KB
testcase_31 AC 162 ms
12,544 KB
testcase_32 AC 104 ms
9,728 KB
testcase_33 AC 149 ms
11,904 KB
testcase_34 AC 120 ms
10,624 KB
testcase_35 AC 95 ms
9,572 KB
testcase_36 AC 234 ms
15,220 KB
testcase_37 AC 230 ms
15,548 KB
testcase_38 AC 55 ms
6,784 KB
testcase_39 AC 193 ms
13,184 KB
testcase_40 AC 232 ms
15,292 KB
testcase_41 AC 32 ms
5,504 KB
testcase_42 AC 196 ms
13,520 KB
testcase_43 AC 140 ms
13,980 KB
testcase_44 AC 155 ms
15,320 KB
testcase_45 AC 173 ms
16,860 KB
testcase_46 AC 22 ms
5,376 KB
testcase_47 AC 155 ms
14,836 KB
testcase_48 AC 135 ms
10,820 KB
testcase_49 AC 23 ms
5,376 KB
testcase_50 AC 74 ms
6,016 KB
testcase_51 AC 5 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 mint = atcoder::static_modint<998244353>;
//using mint = atcoder::static_modint<1000000007>;
using namespace std;
using namespace atcoder;
using ld = long double;
using ll = long long;
#define mp(a,b) make_pair(a,b)
#define rep(i,s,n) for(int i=s; i<n; i++)
const vector<int> dx{1,0,-1,0},dy{0,1,0,-1};

int main(){
    int n,m;
    cin >> n >> m;
    vector<vector<int>> G(n);
    int a,b;
    rep(i,0,m){
        cin >> a >> b;
        a--,b--;
        G[a].push_back(b);
        swap(a,b);
        G[a].push_back(b);
    }
    if(G[0].size()==0){
        rep(i,0,n)cout << 0 << "\n";
        return 0;
    }
    vector<int> dist(n,-1);
    dist[0]=0;
    queue<int> Q;
    Q.push(0);
    vector<int> ans(n+1,0);
    ans[0]++;
    while(Q.size()){
        int x=Q.front();
        Q.pop();
        for(auto y:G[x])if(dist[y]==-1){
            Q.push(y);
            dist[y]=dist[x]+1;
            ans[dist[y]]++;
        }
    }

    rep(i,0,n-1)ans[i+2]+=ans[i];
    rep(i,1,n+1)cout << ans[i] << "\n";
}
0