結果

問題 No.1928 Make a Binary Tree
ユーザー tailstails
提出日時 2022-05-06 22:26:49
言語 cLay
(20240104-1)
結果
AC  
実行時間 62 ms / 3,000 ms
コード長 544 bytes
コンパイル時間 4,368 ms
コンパイル使用メモリ 177,220 KB
実行使用メモリ 44,332 KB
最終ジャッジ日時 2023-09-20 03:26:11
合計ジャッジ時間 8,553 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 3 ms
4,380 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 3 ms
4,376 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 3 ms
4,376 KB
testcase_22 AC 3 ms
4,380 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 3 ms
4,384 KB
testcase_25 AC 3 ms
4,376 KB
testcase_26 AC 51 ms
11,244 KB
testcase_27 AC 26 ms
10,360 KB
testcase_28 AC 31 ms
10,576 KB
testcase_29 AC 56 ms
13,640 KB
testcase_30 AC 22 ms
8,352 KB
testcase_31 AC 34 ms
10,576 KB
testcase_32 AC 57 ms
13,444 KB
testcase_33 AC 25 ms
10,404 KB
testcase_34 AC 33 ms
10,656 KB
testcase_35 AC 17 ms
13,304 KB
testcase_36 AC 39 ms
29,448 KB
testcase_37 AC 35 ms
13,952 KB
testcase_38 AC 2 ms
4,380 KB
testcase_39 AC 47 ms
29,000 KB
testcase_40 AC 48 ms
28,924 KB
testcase_41 AC 50 ms
29,028 KB
testcase_42 AC 47 ms
28,912 KB
testcase_43 AC 48 ms
28,872 KB
testcase_44 AC 51 ms
28,896 KB
testcase_45 AC 48 ms
28,828 KB
testcase_46 AC 48 ms
29,136 KB
testcase_47 AC 50 ms
28,920 KB
testcase_48 AC 48 ms
28,904 KB
testcase_49 AC 40 ms
44,332 KB
testcase_50 AC 40 ms
13,124 KB
testcase_51 AC 45 ms
12,992 KB
testcase_52 AC 43 ms
13,100 KB
testcase_53 AC 43 ms
13,304 KB
testcase_54 AC 40 ms
13,128 KB
testcase_55 AC 38 ms
31,964 KB
testcase_56 AC 61 ms
13,764 KB
testcase_57 AC 62 ms
13,720 KB
testcase_58 AC 58 ms
13,600 KB
testcase_59 AC 42 ms
14,796 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

graph g;
priority_queue<ll> f(ll i,ll p){
	priority_queue<ll> q;
	rep[g.edge[i]](j,g.es[i]){
		if(j!=p){
			auto r=f(j,i);
			if(r.size()>q.size()){
				swap(r,q);
			}
			while(!r.empty()){
				ll x=r.top();
				r.pop();
				q.push(x);
			}
		}
	}
	if(q.size()==0){
		q.push(1);
	}
	else
	if(q.size()==1){
		ll x=q.top();
		q.pop();
		q.push(x+1);
	}
	else{
		ll x=q.top();
		q.pop();
		ll y=q.top();
		q.pop();
		q.push(x+y+1);
	}
	return q;
}
{
	ll@n;
	int a[n],b[];
	rd((a,b)(n-1));
	g.setEdge(n+1,n-1,a,b);
	auto r=f(1,1);
	wt(r.top());
}
0