結果

問題 No.498 ワープクリスタル (給料日編)
ユーザー tossytossy
提出日時 2017-04-06 00:03:28
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 624 ms / 2,000 ms
コード長 1,396 bytes
コンパイル時間 1,711 ms
コンパイル使用メモリ 176,516 KB
実行使用メモリ 73,336 KB
最終ジャッジ日時 2023-09-22 20:30:04
合計ジャッジ時間 8,795 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 7 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 584 ms
73,072 KB
testcase_07 AC 74 ms
8,820 KB
testcase_08 AC 613 ms
73,044 KB
testcase_09 AC 564 ms
73,056 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 3 ms
4,376 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 12 ms
5,620 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 567 ms
73,092 KB
testcase_19 AC 605 ms
73,332 KB
testcase_20 AC 597 ms
73,052 KB
testcase_21 AC 600 ms
73,104 KB
testcase_22 AC 596 ms
73,072 KB
testcase_23 AC 624 ms
73,092 KB
testcase_24 AC 615 ms
73,336 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0