結果

問題 No.498 ワープクリスタル (給料日編)
ユーザー gigimegigime
提出日時 2017-03-24 22:58:48
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,000 bytes
コンパイル時間 1,705 ms
コンパイル使用メモリ 171,624 KB
実行使用メモリ 5,256 KB
最終ジャッジ日時 2023-09-20 02:41:55
合計ジャッジ時間 5,214 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 8 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 RE -
testcase_05 AC 5 ms
4,376 KB
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 AC 3 ms
4,380 KB
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#define FOR(i,l,r) for(int i = (int) (l);i < (int) (r);i++)
#define ALL(x) x.begin(),x.end()
template<typename T> bool chmax(T& a,const T& b){ return a < b ? (a = b,true) : false; }
template<typename T> bool chmin(T& a,const T& b){ return b < a ? (a = b,true) : false; }
typedef long long ll;

int gx,gy,N,K;
ll dp [1 << 15];
const ll MOD = 1e9 + 7;

int main()
{
	scanf("%d%d%d",&gx,&gy,&K);
	vector<int> X(K),Y(K),C(K),A;
	FOR(i,0,K){
		scanf("%d%d%d",&X [i],&Y [i],&C [i]);
		N += C [i];
		FOR(j,0,C [i]) A.push_back(i);
	}

	dp [0] = 1;
	FOR(mask,0,1 << N){
		deque<bool> used(K);
		FOR(i,0,N) if((mask >> i & 1) == 0){
			if(used [A [i]]) continue;
			(dp [mask | (1 << i)] += dp [mask]) %= MOD;
			used [A [i]] = true;
		}
	}

	ll ans = 0;
	FOR(mask,0,1 << N){
		int x = 0,y = 0;
		FOR(i,0,N) if(mask >> i & 1){
			x += X [A [i]];
			y += Y [A [i]];
		}
		if(x == gx && y == gy) (ans += dp [mask]) %= MOD;
	}

	printf("%lld\n",ans);

	return 0;
}
0