結果

問題 No.806 木を道に
ユーザー sggkshiosggkshio
提出日時 2019-10-01 00:29:07
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 71 ms / 2,000 ms
コード長 721 bytes
コンパイル時間 1,712 ms
コンパイル使用メモリ 87,284 KB
実行使用メモリ 9,268 KB
最終ジャッジ日時 2023-07-26 18:54:49
合計ジャッジ時間 3,784 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,384 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,384 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,384 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 15 ms
4,380 KB
testcase_11 AC 13 ms
4,380 KB
testcase_12 AC 58 ms
8,188 KB
testcase_13 AC 41 ms
6,736 KB
testcase_14 AC 54 ms
7,884 KB
testcase_15 AC 58 ms
8,304 KB
testcase_16 AC 22 ms
4,832 KB
testcase_17 AC 54 ms
7,540 KB
testcase_18 AC 6 ms
4,380 KB
testcase_19 AC 16 ms
4,384 KB
testcase_20 AC 51 ms
7,632 KB
testcase_21 AC 28 ms
5,488 KB
testcase_22 AC 71 ms
8,948 KB
testcase_23 AC 69 ms
8,860 KB
testcase_24 AC 34 ms
6,236 KB
testcase_25 AC 50 ms
7,884 KB
testcase_26 AC 17 ms
5,064 KB
testcase_27 AC 57 ms
9,268 KB
testcase_28 AC 3 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #



#define _USE_MATH_DEFINES
#include  <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include <stdlib.h>
#include<stdio.h>
#include <queue>
#include<map>
#include <sstream>
#include<set>
#include<stack>

//#include<bits/stdc++.h>


using namespace std;	



int main() {

	int n;
	cin >> n;
	
	
	vector<int>p(n);
	vector<vector<int>>x(n);
	for (int i = 0; i < n - 1; i++) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		p[a]++; p[b]++;
		x[a].push_back(b);
		x[b].push_back(a);
		
	}
	long long int ans = 0;
	for (int i = 0; i < n; i++) {
		if (p[i] > 2)ans += p[i] - 2;
	}
	cout << ans << endl;



	return 0;




}
0