結果

問題 No.912 赤黒木
ユーザー leaf_1415leaf_1415
提出日時 2019-10-18 23:13:17
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 596 bytes
コンパイル時間 829 ms
コンパイル使用メモリ 63,888 KB
実行使用メモリ 27,984 KB
最終ジャッジ日時 2023-09-08 02:11:05
合計ジャッジ時間 6,443 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
12,848 KB
testcase_01 AC 6 ms
12,772 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 200 ms
24,724 KB
testcase_29 AC 194 ms
24,764 KB
testcase_30 AC 175 ms
25,944 KB
testcase_31 AC 160 ms
25,068 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#define llint long long

using namespace std;

typedef pair<llint, llint> P;

llint n;
vector<llint> g[200005], G[200005];;

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	llint u, v;
	for(int i = 0; i < n-1; i++){
		cin >> u >> v;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	for(int i = 0; i < n-1; i++){
		cin >> u >> v;
		G[u].push_back(v);
		G[v].push_back(u);
	}
	
	llint ans = n-1;
	for(int i = 1; i <= n; i++){
		ans += ((int)G[i].size()+1)/2 - 1;
	}
	cout << ans << endl;
	
	return 0;
}
0