結果

問題 No.806 木を道に
ユーザー furafura
提出日時 2020-05-05 14:23:34
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 44 ms / 2,000 ms
コード長 425 bytes
コンパイル時間 2,275 ms
コンパイル使用メモリ 202,496 KB
実行使用メモリ 8,820 KB
最終ジャッジ日時 2023-09-08 15:51:57
合計ジャッジ時間 3,743 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 9 ms
4,460 KB
testcase_11 AC 8 ms
4,376 KB
testcase_12 AC 34 ms
7,912 KB
testcase_13 AC 24 ms
6,532 KB
testcase_14 AC 31 ms
7,632 KB
testcase_15 AC 35 ms
7,888 KB
testcase_16 AC 13 ms
4,716 KB
testcase_17 AC 29 ms
7,436 KB
testcase_18 AC 4 ms
4,380 KB
testcase_19 AC 9 ms
4,420 KB
testcase_20 AC 30 ms
7,004 KB
testcase_21 AC 17 ms
5,516 KB
testcase_22 AC 44 ms
8,576 KB
testcase_23 AC 44 ms
8,584 KB
testcase_24 AC 18 ms
5,932 KB
testcase_25 AC 26 ms
7,528 KB
testcase_26 AC 10 ms
4,900 KB
testcase_27 AC 30 ms
8,820 KB
testcase_28 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

using graph=vector<vector<int>>;

void add_edge(graph& G,int u,int v){
	G[u].emplace_back(v);
	G[v].emplace_back(u);
}

int main(){
	int n; scanf("%d",&n);
	graph T(n);
	rep(i,n-1){
		int u,v; scanf("%d%d",&u,&v); u--; v--;
		add_edge(T,u,v);
	}

	int ans=0;
	rep(u,n) ans+=max(int(T[u].size())-2,0);
	printf("%d\n",ans);

	return 0;
}
0