結果

問題 No.767 配られたジャパリまん
ユーザー tailstails
提出日時 2018-12-15 15:02:44
言語 cLay
(20240104-1)
結果
TLE  
実行時間 -
コード長 686 bytes
コンパイル時間 6,671 ms
コンパイル使用メモリ 212,696 KB
実行使用メモリ 11,796 KB
最終ジャッジ日時 2023-09-19 00:15:31
合計ジャッジ時間 10,125 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 8 ms
11,680 KB
testcase_01 AC 8 ms
11,672 KB
testcase_02 AC 7 ms
11,544 KB
testcase_03 AC 8 ms
11,528 KB
testcase_04 AC 8 ms
11,796 KB
testcase_05 AC 121 ms
11,528 KB
testcase_06 AC 7 ms
11,728 KB
testcase_07 AC 7 ms
11,524 KB
testcase_08 AC 7 ms
11,596 KB
testcase_09 AC 8 ms
11,584 KB
testcase_10 AC 47 ms
11,732 KB
testcase_11 AC 9 ms
11,536 KB
testcase_12 AC 8 ms
11,644 KB
testcase_13 AC 47 ms
11,796 KB
testcase_14 AC 8 ms
11,768 KB
testcase_15 AC 8 ms
11,668 KB
testcase_16 AC 8 ms
11,600 KB
testcase_17 AC 7 ms
11,520 KB
testcase_18 AC 8 ms
11,516 KB
testcase_19 AC 10 ms
11,604 KB
testcase_20 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#define MD 100000007

int h,w,k;
int a[20],b[20];
mint c[1<<20];
int sorted_a[20],sorted_b[20],sorted_i[20];

{
	combination_mint cm;
	cm.init(2d5);
	
	rd(h,w,k,(a,b)(k));
	copy(a,a+k,sorted_a);
	copy(b,b+k,sorted_b);
	sorted_i[0..k]=(0..);
	sortA(k,sorted_a,sorted_b,sorted_i);

	rep(i,1<<k){
		mint r;
		int pa=0,pb=0;

		r=__builtin_parity(i)?MD-1:1;
		rep(j,k){
			if(i&1<<sorted_i[j]){
				int qa,qb,y,x;
				qa=sorted_a[j];
				qb=sorted_b[j];
				y=qa-pa, x=qb-pb;
				r*=x<0?mint(0):cm.C(y+x,y);
				pa=qa, pb=qb;
			}
		}
		{
			int y,x;
			y=h-pa;
			x=w-pb;
			r*=cm.C(y+x,y);
		}

		for(int j=i;j=j-1&i,r+=(__builtin_parity(i^j)?c[j]:-c[j]),j;){
		}
		c[i]=r;
		wt(r);
	}
}
0