結果

問題 No.2152 [Cherry Anniversary 2] 19 Petals of Cherry
ユーザー tailstails
提出日時 2022-12-09 11:04:32
言語 cLay
(20240104-1)
結果
TLE  
実行時間 -
コード長 876 bytes
コンパイル時間 2,593 ms
コンパイル使用メモリ 173,596 KB
実行使用メモリ 115,640 KB
最終ジャッジ日時 2024-04-22 19:02:51
合計ジャッジ時間 7,002 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

// tabun TLE suru

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

bool pari(unsigned g,unsigned b){
	bool z=false,y=false;
	while(b){
		if(b&1){
			if(g&1){
				z^=y;
			}else{
				y=!y;
			}
		}
		g>>=1;
		b>>=1;
	}
	return z;
}

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;
		for(unsigned g=b;g=g-1&b;){
			if(pc[g]==e){
				auto r1=f(s,g);
				auto r2=f(s+e,b^g);
				if(pari(g,b)){
					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);
	}
	rep(i,19){
		ll@l;
		rep(l){
			ll@a;
			bs[i]|=1<<a-1;
		}
	}
	auto r=f(0,(1<<19)-1);
	wt(r);
}

0