結果

問題 No.1111 コード進行
ユーザー NewGardenNewGarden
提出日時 2020-07-10 22:06:43
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 466 ms / 2,000 ms
コード長 1,974 bytes
コンパイル時間 1,520 ms
コンパイル使用メモリ 128,096 KB
実行使用メモリ 466,688 KB
最終ジャッジ日時 2024-04-19 17:17:22
合計ジャッジ時間 24,568 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 399 ms
466,432 KB
testcase_01 AC 394 ms
466,432 KB
testcase_02 AC 391 ms
466,432 KB
testcase_03 AC 391 ms
466,560 KB
testcase_04 AC 395 ms
466,560 KB
testcase_05 AC 391 ms
466,432 KB
testcase_06 AC 385 ms
466,432 KB
testcase_07 AC 391 ms
466,560 KB
testcase_08 AC 395 ms
466,560 KB
testcase_09 AC 393 ms
466,560 KB
testcase_10 AC 386 ms
466,432 KB
testcase_11 AC 389 ms
466,432 KB
testcase_12 AC 394 ms
466,560 KB
testcase_13 AC 387 ms
466,432 KB
testcase_14 AC 391 ms
466,560 KB
testcase_15 AC 389 ms
466,560 KB
testcase_16 AC 396 ms
466,432 KB
testcase_17 AC 380 ms
466,560 KB
testcase_18 AC 384 ms
466,432 KB
testcase_19 AC 391 ms
466,688 KB
testcase_20 AC 387 ms
466,560 KB
testcase_21 AC 386 ms
466,560 KB
testcase_22 AC 399 ms
466,560 KB
testcase_23 AC 389 ms
466,432 KB
testcase_24 AC 392 ms
466,560 KB
testcase_25 AC 387 ms
466,432 KB
testcase_26 AC 384 ms
466,560 KB
testcase_27 AC 395 ms
466,560 KB
testcase_28 AC 413 ms
466,432 KB
testcase_29 AC 405 ms
466,432 KB
testcase_30 AC 417 ms
466,432 KB
testcase_31 AC 399 ms
466,560 KB
testcase_32 AC 409 ms
466,432 KB
testcase_33 AC 410 ms
466,432 KB
testcase_34 AC 413 ms
466,432 KB
testcase_35 AC 417 ms
466,560 KB
testcase_36 AC 453 ms
466,432 KB
testcase_37 AC 429 ms
466,432 KB
testcase_38 AC 412 ms
466,560 KB
testcase_39 AC 429 ms
466,432 KB
testcase_40 AC 436 ms
466,432 KB
testcase_41 AC 418 ms
466,560 KB
testcase_42 AC 418 ms
466,560 KB
testcase_43 AC 407 ms
466,432 KB
testcase_44 AC 397 ms
466,432 KB
testcase_45 AC 411 ms
466,432 KB
testcase_46 AC 383 ms
466,432 KB
testcase_47 AC 466 ms
466,560 KB
testcase_48 AC 390 ms
466,432 KB
testcase_49 AC 395 ms
466,560 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(ll i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
constexpr char ln = '\n';

const int mx=200010;
const ll mod=1e9+7;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    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; }
};

int main(){
  int n,m,l;
  cin >> n >> m >> l;
  vector<P> v[310];
  rep(i,m){
    int x,y,c; cin >> x >> y >> c; x--; y--;
    v[x].emplace_back(y,c);
  }

  vector<vector<vector<mint>>> dp(310, vector<vector<mint>>(310, vector<mint>(610,0)));
  rep(i,300){
    dp[0][i][0] = 1;
  }
  rep(i,n-1)rep(j,300)rep(k,l+1){
    for(auto it:v[j]){
      dp[i+1][it.F][k+it.S] += dp[i][j][k];
    }
  }
  mint ans = 0;
  rep(i,300){
    ans += dp[n-1][i][l];
  }
  cout << ans.x << ln;
  return 0;
}
0