結果
問題 | No.2888 Mamehinata |
ユーザー |
![]() |
提出日時 | 2024-09-13 21:35:48 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,463 bytes |
コンパイル時間 | 3,313 ms |
コンパイル使用メモリ | 254,892 KB |
実行使用メモリ | 22,656 KB |
最終ジャッジ日時 | 2024-09-13 21:36:08 |
合計ジャッジ時間 | 17,940 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 45 WA * 7 |
ソースコード
#include <bits/stdc++.h>using namespace std;template <class T>struct Edge {Edge() {}Edge(int to_, T cost_) : to(to_), cost(cost_) {}Edge(int from_, int to_, T cost_) : from(from_), to(to_), cost(cost_) {}Edge(int from_, int to_, T cost_, int idx_) : from(from_), to(to_), cost(cost_), idx(idx_) {}int from, to;T cost;int idx;};template <class T> using Graph = vector<vector<Edge<T>>>;using graph = Graph<long long>;using edge = Edge<long long>;#define add emplace_backint main() {int n, m;cin >> n >> m;graph g(n);for (int i = 0; i < m; i++) {int u, v;cin >> u >> v;u--;v--;g[u].add(v, 1LL);g[v].add(u, 1LL);}vector<int> d(n, -1);d[0] = 0;queue<int> q;q.push(0);while (!q.empty()) {int v = q.front();q.pop();for (auto e : g[v]) {int nv = e.to;if (d[nv] != -1) {continue;}d[nv] = d[v] + 1;q.push(nv);}}vector<int> cnt(200010, 0);for (int i = 0; i < n; i++) {if (d[i] >= 0) {cnt[d[i]]++;}}int even = cnt[0], odd = 0;for (int i = 1; i <= n; i++) {if (i % 2 == 0) {even += cnt[i];cout << even << endl;} else {odd += cnt[i];cout << odd << endl;}}}