結果

問題 No.768 Tapris and Noel play the game on Treeone
ユーザー tailstails
提出日時 2018-12-16 01:05:18
言語 cLay
(20231016-1)
結果
AC  
実行時間 43 ms / 2,000 ms
コード長 428 bytes
コンパイル時間 2,281 ms
コンパイル使用メモリ 164,980 KB
実行使用メモリ 12,320 KB
最終ジャッジ日時 2023-09-19 00:15:41
合計ジャッジ時間 4,063 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
6,864 KB
testcase_01 AC 3 ms
6,660 KB
testcase_02 AC 3 ms
6,712 KB
testcase_03 AC 3 ms
6,736 KB
testcase_04 AC 3 ms
6,764 KB
testcase_05 AC 4 ms
6,696 KB
testcase_06 AC 3 ms
6,680 KB
testcase_07 AC 24 ms
9,760 KB
testcase_08 AC 14 ms
8,316 KB
testcase_09 AC 15 ms
8,584 KB
testcase_10 AC 12 ms
8,116 KB
testcase_11 AC 39 ms
11,576 KB
testcase_12 AC 37 ms
11,532 KB
testcase_13 AC 35 ms
11,480 KB
testcase_14 AC 36 ms
11,356 KB
testcase_15 AC 40 ms
11,640 KB
testcase_16 AC 43 ms
11,616 KB
testcase_17 AC 42 ms
11,760 KB
testcase_18 AC 31 ms
12,108 KB
testcase_19 AC 29 ms
11,992 KB
testcase_20 AC 27 ms
12,320 KB
testcase_21 AC 25 ms
12,056 KB
20evil_special_uni1.txt AC 33 ms
11,920 KB
20evil_special_uni2.txt AC 32 ms
11,664 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

int n,a[2d5];
vector<int> v[1d5];
int g[1d5];
int h[1d5];
int m;

int f1(int b,int p){
	int r=0;
	for(int c:v[b]){
		if(c!=p&&!f1(c,b)){
			r+=1;
		}
	}
	return g[b]=r;
}

void f2(int b,int p,int d){
	for(int c:v[b]){
		if(c!=p){
			f2(c,b,!(g[b]-!g[c]||d));
		}
	}
	m+=h[b]=!(g[b]||d);
}

{
	rd(n,a(n*2-2));
	rep(i,n*2-2){
		v[a[i]-1].push_back(a[i^1]-1);
	}
	f1(0,-1);
	f2(0,-1,0);
	wt(m);
	rep(i,n){
		if(h[i]) wt(i+1);
	}
}
0