結果

問題 No.806 木を道に
ユーザー sggkshio
提出日時 2019-10-01 00:29:07
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 70 ms / 2,000 ms
コード長 721 bytes
コンパイル時間 739 ms
コンパイル使用メモリ 89,428 KB
実行使用メモリ 9,160 KB
最終ジャッジ日時 2024-10-03 05:31:58
合計ジャッジ時間 2,178 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

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