結果

問題 No.806 木を道に
ユーザー leaf_1415leaf_1415
提出日時 2019-03-22 21:34:08
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 85 ms / 2,000 ms
コード長 355 bytes
コンパイル時間 550 ms
コンパイル使用メモリ 60,972 KB
実行使用メモリ 9,096 KB
最終ジャッジ日時 2023-10-19 06:33:18
合計ジャッジ時間 2,637 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
5,940 KB
testcase_01 AC 3 ms
5,940 KB
testcase_02 AC 3 ms
5,944 KB
testcase_03 AC 3 ms
5,944 KB
testcase_04 AC 3 ms
5,940 KB
testcase_05 AC 3 ms
5,944 KB
testcase_06 AC 4 ms
5,944 KB
testcase_07 AC 3 ms
5,940 KB
testcase_08 AC 4 ms
5,940 KB
testcase_09 AC 3 ms
5,944 KB
testcase_10 AC 19 ms
6,636 KB
testcase_11 AC 17 ms
6,560 KB
testcase_12 AC 71 ms
8,616 KB
testcase_13 AC 52 ms
7,880 KB
testcase_14 AC 69 ms
8,484 KB
testcase_15 AC 73 ms
8,656 KB
testcase_16 AC 27 ms
6,916 KB
testcase_17 AC 63 ms
8,284 KB
testcase_18 AC 9 ms
6,200 KB
testcase_19 AC 20 ms
6,672 KB
testcase_20 AC 62 ms
8,288 KB
testcase_21 AC 35 ms
7,264 KB
testcase_22 AC 85 ms
9,096 KB
testcase_23 AC 84 ms
9,096 KB
testcase_24 AC 38 ms
7,588 KB
testcase_25 AC 56 ms
8,440 KB
testcase_26 AC 21 ms
6,876 KB
testcase_27 AC 65 ms
9,048 KB
testcase_28 AC 5 ms
6,044 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>

using namespace std;

int n;
vector<int> G[100005];

int main(void)
{
	cin >> n;
	int u, v;
	for(int i = 0; i < n-1; i++){
		cin >> u >> v;
		G[u].push_back(v);
		G[v].push_back(u);
	}
	
	int ans = 0;
	for(int i = 1; i <= n; i++){
		if(G[i].size() > 2) ans += G[i].size() - 2;
	}
	cout << ans << endl;
	
	return 0;
}
0