結果

問題 No.806 木を道に
ユーザー baku1101baku1101
提出日時 2019-03-22 21:46:44
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 88 ms / 2,000 ms
コード長 1,636 bytes
コンパイル時間 1,814 ms
コンパイル使用メモリ 172,392 KB
実行使用メモリ 9,440 KB
最終ジャッジ日時 2023-10-19 07:45:58
合計ジャッジ時間 3,802 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 18 ms
4,688 KB
testcase_11 AC 17 ms
4,436 KB
testcase_12 AC 74 ms
8,384 KB
testcase_13 AC 51 ms
7,064 KB
testcase_14 AC 70 ms
8,120 KB
testcase_15 AC 75 ms
8,648 KB
testcase_16 AC 26 ms
5,216 KB
testcase_17 AC 64 ms
7,856 KB
testcase_18 AC 7 ms
4,348 KB
testcase_19 AC 19 ms
4,688 KB
testcase_20 AC 63 ms
7,856 KB
testcase_21 AC 34 ms
6,008 KB
testcase_22 AC 86 ms
9,440 KB
testcase_23 AC 88 ms
9,440 KB
testcase_24 AC 38 ms
6,272 KB
testcase_25 AC 56 ms
7,856 KB
testcase_26 AC 21 ms
5,384 KB
testcase_27 AC 66 ms
9,420 KB
testcase_28 AC 3 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

//MOD
//--------------------------------------------
#define MUL(a,b) (((a) % MOD) * ((b) % MOD)) % MOD

// grid
//--------------------------------------------
VL dx = {0, 1, 0, -1};
VL dy = {1, 0, -1, 0};
VL dx2 = {-1, 0, 1, -1, 1, -1, 0, 1};
VL dy2 = {-1, -1, -1, 0, 0, 1, 1, 1};

//debug
//--------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//main code
int main(int argc, char const* argv[])
{
	int n;
	cin >> n;
	VVL v(n);
	for (int i = 0; i < n-1; i++) {
		int a,b;
		cin >> a >> b;
		a--;
		b--;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	LL ans = 0;
	for (int i = 0; i < n; i++) {
		if (v[i].size() > 2) {
			ans += v[i].size() - 2;
		}
	}
	cout << ans << endl;
	return 0;
}

0