結果
問題 | No.2888 Mamehinata |
ユーザー |
![]() |
提出日時 | 2024-09-13 22:28:13 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,083 bytes |
コンパイル時間 | 3,365 ms |
コンパイル使用メモリ | 254,848 KB |
実行使用メモリ | 17,500 KB |
最終ジャッジ日時 | 2024-09-13 22:28:24 |
合計ジャッジ時間 | 11,816 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 45 WA * 7 |
ソースコード
#include <bits/stdc++.h>using namespace std;using ll = long long;const int INF = 1e9 + 10;const ll INFL = 4e18;int main() {int N, M;cin >> N >> M;vector<vector<int>> G(N);for (int i = 0; i < M; i++) {int u, v;cin >> u >> v;u--;v--;G[u].push_back(v);G[v].push_back(u);}vector<int> dst(N, INF);dst[0] = 0;queue<int> que;que.push(0);while (!que.empty()) {int now = que.front();que.pop();for (int nxt : G[now]) {if (dst[nxt] > dst[now] + 1) {dst[nxt] = dst[now] + 1;que.push(nxt);}}}vector<ll> ans(N + 1);for (int i = 0; i < N; i++) {if (dst[i] != INF) ans[dst[i]]++;}if (dst[1] == 0) {for (int i = 1; i <= N; i++) {cout << 0 << '\n';}return 0;}for (int i = 0; i + 2 <= N; i++) {ans[i + 2] += ans[i];}for (int i = 1; i <= N; i++) {cout << ans[i] << '\n';}}