結果

問題 No.767 配られたジャパリまん
ユーザー kotatsugamekotatsugame
提出日時 2020-03-06 05:56:48
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,035 bytes
コンパイル時間 775 ms
コンパイル使用メモリ 72,416 KB
実行使用メモリ 15,744 KB
最終ジャッジ日時 2024-04-22 03:42:41
合計ジャッジ時間 3,274 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 10 ms
7,680 KB
testcase_01 AC 10 ms
7,680 KB
testcase_02 AC 10 ms
7,680 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 11 ms
7,552 KB
testcase_07 AC 11 ms
7,552 KB
testcase_08 AC 10 ms
7,808 KB
testcase_09 AC 10 ms
7,680 KB
testcase_10 AC 24 ms
7,936 KB
testcase_11 AC 11 ms
7,552 KB
testcase_12 AC 11 ms
7,552 KB
testcase_13 AC 24 ms
7,808 KB
testcase_14 AC 11 ms
7,680 KB
testcase_15 AC 11 ms
7,808 KB
testcase_16 AC 11 ms
7,552 KB
testcase_17 AC 9 ms
7,680 KB
testcase_18 AC 11 ms
7,680 KB
testcase_19 AC 11 ms
7,680 KB
testcase_20 AC 431 ms
15,744 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:11:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   11 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<algorithm>
using namespace std;
long mod=1e8+7;
long power(long a,long b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}
long F[2<<17],I[2<<17];
long C(int N,int K){return F[N]*I[N-K]%mod*I[K]%mod;}
int H,W,K;
pair<int,int>ab[20];
long A[1<<20];
main()
{
	F[0]=1;
	for(int i=1;i<2<<17;i++)F[i]=F[i-1]*i%mod;
	I[(2<<17)-1]=power(F[(2<<17)-1],mod-2);
	for(int i=(2<<17)-1;i--;)I[i]=I[i+1]*(i+1)%mod;
	cin>>H>>W>>K;
	for(int i=0;i<K;i++)cin>>ab[i].first>>ab[i].second;
	sort(ab,ab+K);
	for(int i=0;i<1<<K;i++)
	{
		int nx=0,ny=0;
		long ans=1;
		int pc=0;
		for(int j=0;j<K;j++)
		{
			if(i>>j&1)
			{
				pc++;
				if(nx<=ab[j].first&&ny<=ab[j].second)
				{
					int dx=ab[j].first-nx,dy=ab[j].second-ny;
					ans=ans*C(dx+dy,dx)%mod;
					nx=ab[j].first;
					ny=ab[j].second;
				}
				else ans=0;
			}
		}
		int dx=H-nx,dy=W-ny;
		ans=ans*C(dx+dy,dx)%mod;
		A[i]=pc%2?mod-ans:ans;
	}
	for(int i=0;i<K;i++)for(int j=0;j<1<<K;j++)if(j>>i&1)(A[j]+=A[j^1<<i])%=mod;
	for(int i=0;i<1<<K;i++)cout<<A[i]<<"\n";
}
0