結果
問題 | No.2888 Mamehinata |
ユーザー |
|
提出日時 | 2024-09-14 20:51:42 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 157 ms / 2,000 ms |
コード長 | 1,005 bytes |
コンパイル時間 | 4,106 ms |
コンパイル使用メモリ | 254,644 KB |
最終ジャッジ日時 | 2025-02-24 08:40:21 |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 52 |
ソースコード
#include <atcoder/all>#include <bits/stdc++.h>using namespace std;using ll = long long;#define rep(i, s, t) for (ll i = s; i < (ll)(t); i++)template<typename T>bool chmin(T &x, T y) { return x > y ? (x = y, true) : false; }template<typename T>bool chmax(T &x, T y) { return x < y ? (x = y, true) : false; }struct io_setup {io_setup() {ios::sync_with_stdio(false);std::cin.tie(nullptr);cout << fixed << setprecision(15);}} io_setup;int main(){int n,m;cin>>n>>m;vector<vector<int>> g(n);rep(i,0,m){int a,b;cin>>a>>b;a--; b--;g.at(a).push_back(b);g.at(b).push_back(a);}vector<int> sm(n+1,0);queue<pair<int,int>> q;q.push({0,0});vector<int> stl(n,0);while(!q.empty()){auto[nw,h]=q.front();q.pop();if(stl.at(nw)) continue;stl.at(nw)=1;sm.at(h)++;for(int nx:g.at(nw)){if(stl.at(nx)) continue;q.push({nx,h+1});}}int nw1=0,nw2=(sm.at(1)>0?1:0);rep(i,1,n+1){nw1+=sm.at(i);cout<<nw1<<"\n";swap(nw1,nw2);}}