結果

問題 No.2888 Mamehinata
ユーザー eve__fuyukieve__fuyuki
提出日時 2024-09-14 15:30:02
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 880 bytes
コンパイル時間 2,551 ms
コンパイル使用メモリ 208,368 KB
実行使用メモリ 16,756 KB
最終ジャッジ日時 2024-09-14 15:30:12
合計ジャッジ時間 8,677 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 3 ms
5,376 KB
testcase_04 WA -
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 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 WA -
testcase_12 AC 3 ms
5,376 KB
testcase_13 AC 20 ms
5,376 KB
testcase_14 AC 23 ms
7,296 KB
testcase_15 WA -
testcase_16 AC 103 ms
13,184 KB
testcase_17 WA -
testcase_18 AC 41 ms
5,888 KB
testcase_19 AC 118 ms
13,056 KB
testcase_20 AC 102 ms
11,392 KB
testcase_21 AC 99 ms
11,136 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 115 ms
14,208 KB
testcase_25 AC 85 ms
13,824 KB
testcase_26 AC 84 ms
13,696 KB
testcase_27 AC 43 ms
11,648 KB
testcase_28 AC 15 ms
5,376 KB
testcase_29 AC 37 ms
7,680 KB
testcase_30 AC 129 ms
14,080 KB
testcase_31 AC 98 ms
12,288 KB
testcase_32 AC 57 ms
9,728 KB
testcase_33 AC 75 ms
11,776 KB
testcase_34 AC 59 ms
10,496 KB
testcase_35 AC 53 ms
9,472 KB
testcase_36 AC 134 ms
15,232 KB
testcase_37 AC 132 ms
15,488 KB
testcase_38 AC 29 ms
6,784 KB
testcase_39 AC 117 ms
13,184 KB
testcase_40 AC 140 ms
15,232 KB
testcase_41 AC 19 ms
5,376 KB
testcase_42 AC 120 ms
13,568 KB
testcase_43 AC 73 ms
13,896 KB
testcase_44 AC 81 ms
15,216 KB
testcase_45 AC 97 ms
16,756 KB
testcase_46 AC 12 ms
5,376 KB
testcase_47 AC 86 ms
14,732 KB
testcase_48 AC 65 ms
10,708 KB
testcase_49 AC 10 ms
5,376 KB
testcase_50 AC 29 ms
5,888 KB
testcase_51 AC 3 ms
5,376 KB
testcase_52 AC 2 ms
5,376 KB
testcase_53 AC 5 ms
5,376 KB
testcase_54 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

void fast_io() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
}

int main() {
	fast_io();
	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);
	}
	if (g[0].empty()) {
		for (int i = 0; i < n; i++) {
			cout << "1\n";
		}
		return 0;
	}
	vector<int> dist(n, -1);
	dist[0] = 0;
	deque<int> dq;
	dq.push_back(0);
	while (!dq.empty()) {
		int u = dq.front();
		dq.pop_front();
		for (int v : g[u]) {
			if (dist[v] == -1) {
				dist[v] = dist[u] + 1;
				dq.push_back(v);
			}
		}
	}
	vector<int> ans(n + 1, 0);
	for (int i = 0; i < n; i++) {
		if (dist[i] != -1) {
			ans[dist[i]]++;
		}
	}
	for (int i = 2; i <= n; i++) {
		ans[i] += ans[i - 2];
	}
	for (int i = 1; i <= n; i++) {
		cout << ans[i] << "\n";
	}
}
0