結果

問題 No.2152 [Cherry Anniversary 2] 19 Petals of Cherry
ユーザー tailstails
提出日時 2022-12-09 11:40:45
言語 cLay
(20240104-1)
結果
AC  
実行時間 377 ms / 1,000 ms
コード長 749 bytes
コンパイル時間 2,497 ms
コンパイル使用メモリ 174,224 KB
実行使用メモリ 31,488 KB
最終ジャッジ日時 2024-04-22 19:03:56
合計ジャッジ時間 21,965 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 358 ms
31,360 KB
testcase_01 AC 362 ms
31,488 KB
testcase_02 AC 360 ms
31,488 KB
testcase_03 AC 357 ms
31,360 KB
testcase_04 AC 361 ms
31,488 KB
testcase_05 AC 361 ms
31,360 KB
testcase_06 AC 365 ms
31,360 KB
testcase_07 AC 367 ms
31,488 KB
testcase_08 AC 362 ms
31,232 KB
testcase_09 AC 358 ms
31,232 KB
testcase_10 AC 362 ms
31,488 KB
testcase_11 AC 358 ms
31,360 KB
testcase_12 AC 358 ms
31,360 KB
testcase_13 AC 363 ms
31,488 KB
testcase_14 AC 364 ms
31,488 KB
testcase_15 AC 365 ms
31,360 KB
testcase_16 AC 359 ms
31,360 KB
testcase_17 AC 360 ms
31,488 KB
testcase_18 AC 365 ms
31,488 KB
testcase_19 AC 356 ms
31,488 KB
testcase_20 AC 366 ms
31,488 KB
testcase_21 AC 362 ms
31,360 KB
testcase_22 AC 366 ms
31,360 KB
testcase_23 AC 370 ms
31,488 KB
testcase_24 AC 357 ms
31,488 KB
testcase_25 AC 366 ms
31,360 KB
testcase_26 AC 366 ms
31,488 KB
testcase_27 AC 363 ms
31,360 KB
testcase_28 AC 364 ms
31,360 KB
testcase_29 AC 365 ms
31,360 KB
testcase_30 AC 366 ms
31,360 KB
testcase_31 AC 366 ms
31,488 KB
testcase_32 AC 362 ms
31,232 KB
testcase_33 AC 364 ms
31,488 KB
testcase_34 AC 360 ms
31,488 KB
testcase_35 AC 362 ms
31,360 KB
testcase_36 AC 362 ms
31,488 KB
testcase_37 AC 367 ms
31,488 KB
testcase_38 AC 362 ms
31,360 KB
testcase_39 AC 374 ms
31,232 KB
testcase_40 AC 372 ms
31,488 KB
testcase_41 AC 377 ms
31,488 KB
testcase_42 AC 374 ms
31,360 KB
testcase_43 AC 370 ms
31,488 KB
testcase_44 AC 368 ms
31,488 KB
testcase_45 AC 370 ms
31,488 KB
testcase_46 AC 368 ms
31,488 KB
testcase_47 AC 367 ms
31,488 KB
testcase_48 AC 362 ms
31,488 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

char pc[1<<19],pa[1<<19];
unsigned bs[19];

pair<ll,ll> f(int s,unsigned b :Memoize[19,524288]){
	pair<ll,ll> z{};
	int d=pc[b];
	if(d==1){
		z.first=b&bs[s]?1:0;
	}else{
		int e=d>>1;
		int k=0;
		for(unsigned g=b;g=g-1&b;){
			++k;
			if(pc[g]==e){
				auto r1=f(s,b^g);
				auto r2=f(s+(d-e),g);
				if(pa[k]){
					z.first+=r1.first*r2.second+r1.second*r2.first;
					z.second+=r1.first*r2.first+r1.second*r2.second;
				}else{
					z.first+=r1.first*r2.first+r1.second*r2.second;
					z.second+=r1.first*r2.second+r1.second*r2.first;
				}
			}
		}
	}
	return z;
}

{
	rep(i,1<<19){
		pc[i]=__builtin_popcount(i);
		pa[i]=pa[i>>1]^pc[i]&~i&1;
	}
	rep(i,19){
		ll@l;
		rep(l){
			ll@a;
			bs[i]|=1<<a-1;
		}
	}
	auto r=f(0,(1<<19)-1);
	wt(r);
}
0