結果
| 問題 |
No.498 ワープクリスタル (給料日編)
|
| コンテスト | |
| ユーザー |
tossy
|
| 提出日時 | 2017-04-06 00:03:28 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 584 ms / 2,000 ms |
| コード長 | 1,396 bytes |
| コンパイル時間 | 1,617 ms |
| コンパイル使用メモリ | 177,860 KB |
| 実行使用メモリ | 73,216 KB |
| 最終ジャッジ日時 | 2024-07-08 11:08:34 |
| 合計ジャッジ時間 | 8,076 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 21 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}
#define INF 2147483600
#define MOD 1000000007
long comb[100][100];
void init_comb(){
fill(comb[0],comb[100],0);
comb[0][0] = 1;
repl(i,1,100){
comb[i][0] = 1;
rep(j,i) comb[i][j+1] = (comb[i-1][j]+comb[i-1][j+1])%MOD;
}
}
int main(){
init_comb();
int gx,gy,k;
cin>>gx>>gy>>k;
map<pair<int,pair<int,int>>, long> crnt;
crnt[mp(0,mp(0,0))] = 1;
rep(_,k){
map<pair<int,pair<int,int>>, long> nxt(crnt);
int x,y,n;
cin>>x>>y>>n;
for(auto &p : crnt){
repl(i,1,n+1){
(nxt[mp(p.fi.fi+i, mp(p.fi.se.fi+x*i, p.fi.se.se+y*i))] += p.se * comb[p.fi.fi+i][i] %MOD)%=MOD;
}
}
swap(crnt, nxt);
}
long ans = 0;
for(auto &p : crnt) if(p.fi.se.fi==gx && p.fi.se.se==gy) ans += p.se;
cout << ans %MOD << endl;
return 0;
}
tossy