結果
問題 | No.2888 Mamehinata |
ユーザー |
|
提出日時 | 2024-09-13 22:42:21 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,023 bytes |
コンパイル時間 | 2,336 ms |
コンパイル使用メモリ | 208,864 KB |
実行使用メモリ | 15,988 KB |
最終ジャッジ日時 | 2024-09-13 22:42:47 |
合計ジャッジ時間 | 8,055 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge6 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 45 WA * 7 |
ソースコード
#include <bits/stdc++.h> using namespace std; vector<int> BFS(vector<vector<int>> &Graph,int start){ int N = Graph.size(); vector<int> ret(N,-1); queue<int> Q; ret.at(start) = 0,Q.push(start); while(Q.size()){ int pos = Q.front(); Q.pop(); for(auto to : Graph.at(pos)){ if(ret.at(to) != -1) continue; ret.at(to) = ret.at(pos)+1; Q.push(to); } } return ret; } int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int N,M; cin >> N >> M; vector<vector<int>> Graph(N); for(int i=0; i<M; i++){ int u,v; cin >> u >> v; u--; v--; Graph.at(u).push_back(v); Graph.at(v).push_back(u); } vector<int> dist = BFS(Graph,0); vector<int> rev(N+1); for(auto &d : dist) if(d != -1) rev.at(d)++; int one = 1,two = 0; for(int i=1; i<=N; i++){ if(i%2 == 0) one += rev.at(i),cout << one << "\n"; else two += rev.at(i),cout << two << "\n"; } }