結果

問題 No.767 配られたジャパリまん
ユーザー tailstails
提出日時 2018-12-18 17:35:36
言語 cLay
(20240104-1)
結果
AC  
実行時間 113 ms / 2,000 ms
コード長 605 bytes
コンパイル時間 5,975 ms
コンパイル使用メモリ 223,640 KB
実行使用メモリ 23,800 KB
最終ジャッジ日時 2023-09-19 00:16:07
合計ジャッジ時間 7,840 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 12 ms
17,736 KB
testcase_01 AC 11 ms
17,836 KB
testcase_02 AC 11 ms
17,796 KB
testcase_03 AC 11 ms
17,744 KB
testcase_04 AC 12 ms
17,676 KB
testcase_05 AC 19 ms
20,036 KB
testcase_06 AC 11 ms
17,668 KB
testcase_07 AC 12 ms
17,884 KB
testcase_08 AC 11 ms
17,860 KB
testcase_09 AC 12 ms
17,736 KB
testcase_10 AC 15 ms
18,008 KB
testcase_11 AC 11 ms
17,820 KB
testcase_12 AC 12 ms
17,684 KB
testcase_13 AC 15 ms
17,924 KB
testcase_14 AC 11 ms
17,720 KB
testcase_15 AC 11 ms
17,668 KB
testcase_16 AC 12 ms
17,688 KB
testcase_17 AC 11 ms
17,716 KB
testcase_18 AC 12 ms
17,792 KB
testcase_19 AC 11 ms
17,960 KB
testcase_20 AC 113 ms
23,800 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define MD 100000007

int h,w,k,a[20],b[20],c[20],f[1<<20],g[1<<20];
mint d[1<<20],e[1<<20],l;

{
	combination_mint cm;
	cm.init(3d5);
	
	rd(h,w,k,(a,b)(k));
	rep(i,k)c[i]=i;
	sortA(k,a,b,c);

	e[0]=1;
	d[0]=l=cm.C(h+w,h);
	rep(i,1,1<<k){
		int j0=ffs(i)-1;
		int j1=ffs(i&i-1)-1;
		int y=(j1<0?h:a[j1])-a[j0];
		int x=(j1<0?w:b[j1])-b[j0];
		e[i]=e[i&i-1]*cm.C(y+x,y);
		d[i]=e[i]*cm.C(a[j0]+b[j0],a[j0]);
	}
	d[0]=0;
	rep(j,k)rep(i,1<<k)if(i&1<<j)d[i]-=d[i^1<<j];
	rep(i,1,1<<k)f[i]=f[i&i-1]|1<<c[ffs(i)-1];
	rep(i,1<<k)g[i]=l+(__builtin_parity(i)?-d[i]:d[i]);
	sortA(1<<k,f,g);
	rep(i,1<<k)wt(g[i]);
}
0