結果

問題 No.806 木を道に
ユーザー sggkshiosggkshio
提出日時 2019-10-01 00:29:07
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 85 ms / 2,000 ms
コード長 721 bytes
コンパイル時間 888 ms
コンパイル使用メモリ 89,284 KB
実行使用メモリ 9,284 KB
最終ジャッジ日時 2024-04-14 08:26:02
合計ジャッジ時間 3,045 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 1 ms
6,940 KB
testcase_04 AC 1 ms
6,940 KB
testcase_05 AC 1 ms
6,944 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 2 ms
6,940 KB
testcase_10 AC 17 ms
6,940 KB
testcase_11 AC 16 ms
6,940 KB
testcase_12 AC 70 ms
8,192 KB
testcase_13 AC 49 ms
6,944 KB
testcase_14 AC 65 ms
7,808 KB
testcase_15 AC 70 ms
8,192 KB
testcase_16 AC 24 ms
6,940 KB
testcase_17 AC 59 ms
7,424 KB
testcase_18 AC 7 ms
6,944 KB
testcase_19 AC 18 ms
6,940 KB
testcase_20 AC 60 ms
7,424 KB
testcase_21 AC 32 ms
6,940 KB
testcase_22 AC 85 ms
9,088 KB
testcase_23 AC 84 ms
9,036 KB
testcase_24 AC 37 ms
6,940 KB
testcase_25 AC 55 ms
7,936 KB
testcase_26 AC 20 ms
6,944 KB
testcase_27 AC 65 ms
9,284 KB
testcase_28 AC 3 ms
6,944 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