結果

問題 No.806 木を道に
ユーザー aa
提出日時 2019-03-22 23:15:42
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 133 ms / 2,000 ms
コード長 358 bytes
コンパイル時間 1,743 ms
コンパイル使用メモリ 173,468 KB
実行使用メモリ 8,308 KB
最終ジャッジ日時 2023-10-19 10:40:47
合計ジャッジ時間 4,164 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 23 ms
4,652 KB
testcase_11 AC 21 ms
4,540 KB
testcase_12 AC 107 ms
7,596 KB
testcase_13 AC 74 ms
6,504 KB
testcase_14 AC 101 ms
7,400 KB
testcase_15 AC 110 ms
7,656 KB
testcase_16 AC 33 ms
5,068 KB
testcase_17 AC 93 ms
7,104 KB
testcase_18 AC 9 ms
4,348 KB
testcase_19 AC 24 ms
4,704 KB
testcase_20 AC 92 ms
7,104 KB
testcase_21 AC 46 ms
5,584 KB
testcase_22 AC 130 ms
8,308 KB
testcase_23 AC 133 ms
8,308 KB
testcase_24 AC 49 ms
6,092 KB
testcase_25 AC 76 ms
7,372 KB
testcase_26 AC 25 ms
5,024 KB
testcase_27 AC 89 ms
8,204 KB
testcase_28 AC 3 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"

using namespace std;

void solve()
{
	int n, ans = 0;
	cin >> n;
	map<int, int> mp;
	for (int x = 0; x < n - 1; x++)
	{
		int a, b;
		cin >> a >> b;
		mp[a]++;
		mp[b]++;
	}
	for (auto p : mp)
	{
		ans += max(p.second - 2, 0);
	}
	cout << ans << endl;
}

int main(void)
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}
0