結果

問題 No.1111 コード進行
ユーザー chocono2230chocono2230
提出日時 2020-07-10 22:18:03
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,493 bytes
コンパイル時間 1,790 ms
コンパイル使用メモリ 180,080 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-19 17:30:12
合計ジャッジ時間 3,843 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 4 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 WA -
testcase_10 AC 4 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 WA -
testcase_13 AC 3 ms
5,376 KB
testcase_14 WA -
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 5 ms
5,376 KB
testcase_17 AC 5 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 3 ms
5,376 KB
testcase_21 AC 1 ms
5,376 KB
testcase_22 AC 6 ms
5,376 KB
testcase_23 AC 2 ms
5,376 KB
testcase_24 AC 3 ms
5,376 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 2 ms
5,376 KB
testcase_28 AC 50 ms
5,376 KB
testcase_29 AC 18 ms
5,376 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 36 ms
5,376 KB
testcase_35 AC 43 ms
5,376 KB
testcase_36 AC 87 ms
5,376 KB
testcase_37 AC 18 ms
5,376 KB
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 AC 58 ms
5,376 KB
testcase_42 AC 37 ms
5,376 KB
testcase_43 WA -
testcase_44 AC 12 ms
5,376 KB
testcase_45 AC 36 ms
5,376 KB
testcase_46 AC 6 ms
5,376 KB
testcase_47 AC 193 ms
5,376 KB
testcase_48 AC 7 ms
5,376 KB
testcase_49 AC 6 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

const int sz = 300;

int main(){
  int n, m, k;
  cin >> n >> m >> k;
  vector<vector<pair<int, int>>> gr(sz, vector<pair<int, int>>());
  rep(i, m){
    int p, q, c;
    cin >> p >> q >> c;
    p--; q--;
    gr.at(p).push_back(make_pair(q, c));
  }
  vector<vector<mint>> dp(sz, vector<mint>(k+1, 0));
  rep(i, sz){
    dp.at(i).at(0) = 1;
  }
  rep(t, n-1){
    // rep(i, k+1){
    //   rep(j, n) cerr << dp.at(j).at(i).x << " ";
    //   cerr << endl;
    // }
    // cerr << endl;
    vector<vector<mint>> nxdp(sz, vector<mint>(k+1, 0));
    rep(i, sz){
      for(auto p : gr.at(i)){
        rep(j, k-p.second+1){
          nxdp.at(p.first).at(j+p.second) += dp.at(i).at(j);
        }
      }
    }
    dp = nxdp;
  }
  mint ans = 0;
  rep(i, n){
    ans += dp.at(i).at(k);
  }
  cout << ans.x << endl;
  return 0;
}
0