結果

問題 No.912 赤黒木
コンテスト
ユーザー leaf_1415
提出日時 2019-10-18 23:13:17
言語 C++11
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 596 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 405 ms
コンパイル使用メモリ 80,512 KB
実行使用メモリ 28,440 KB
最終ジャッジ日時 2026-03-12 04:52:21
合計ジャッジ時間 4,521 ms
ジャッジサーバーID
(参考情報)
judge3_1 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 4 WA * 26
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#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