結果

問題 No.1111 コード進行
ユーザー cumincumin
提出日時 2020-08-04 15:57:40
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 135 ms / 2,000 ms
コード長 1,136 bytes
コンパイル時間 1,550 ms
コンパイル使用メモリ 165,776 KB
実行使用メモリ 236,404 KB
最終ジャッジ日時 2023-10-12 19:05:27
合計ジャッジ時間 7,314 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 62 ms
236,116 KB
testcase_01 AC 62 ms
236,096 KB
testcase_02 AC 62 ms
236,096 KB
testcase_03 AC 62 ms
236,280 KB
testcase_04 AC 61 ms
236,096 KB
testcase_05 AC 62 ms
236,088 KB
testcase_06 AC 61 ms
236,200 KB
testcase_07 AC 62 ms
236,100 KB
testcase_08 AC 61 ms
236,088 KB
testcase_09 AC 62 ms
236,200 KB
testcase_10 AC 62 ms
236,096 KB
testcase_11 AC 62 ms
236,120 KB
testcase_12 AC 63 ms
236,272 KB
testcase_13 AC 61 ms
236,100 KB
testcase_14 AC 63 ms
236,152 KB
testcase_15 AC 62 ms
236,088 KB
testcase_16 AC 63 ms
236,152 KB
testcase_17 AC 62 ms
236,100 KB
testcase_18 AC 63 ms
236,120 KB
testcase_19 AC 63 ms
236,272 KB
testcase_20 AC 62 ms
236,140 KB
testcase_21 AC 62 ms
236,360 KB
testcase_22 AC 62 ms
236,088 KB
testcase_23 AC 62 ms
236,276 KB
testcase_24 AC 62 ms
236,136 KB
testcase_25 AC 64 ms
236,084 KB
testcase_26 AC 63 ms
236,116 KB
testcase_27 AC 63 ms
236,140 KB
testcase_28 AC 64 ms
236,180 KB
testcase_29 AC 64 ms
236,080 KB
testcase_30 AC 68 ms
236,140 KB
testcase_31 AC 62 ms
236,112 KB
testcase_32 AC 74 ms
236,160 KB
testcase_33 AC 76 ms
236,136 KB
testcase_34 AC 62 ms
236,208 KB
testcase_35 AC 64 ms
236,084 KB
testcase_36 AC 96 ms
236,104 KB
testcase_37 AC 76 ms
236,096 KB
testcase_38 AC 70 ms
236,164 KB
testcase_39 AC 83 ms
236,404 KB
testcase_40 AC 87 ms
236,096 KB
testcase_41 AC 66 ms
236,272 KB
testcase_42 AC 80 ms
236,148 KB
testcase_43 AC 78 ms
236,184 KB
testcase_44 AC 66 ms
236,128 KB
testcase_45 AC 71 ms
236,120 KB
testcase_46 AC 63 ms
236,148 KB
testcase_47 AC 135 ms
236,124 KB
testcase_48 AC 66 ms
236,348 KB
testcase_49 AC 65 ms
236,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(long long)(n);++i)
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1000000007;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};

int n,m,k;
ll dp[310][310][310];
int p[310],q[310],c[310];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  cin >> n >> m >> k;
  rep(i,m){
    cin >> p[i] >> q[i] >> c[i];
    p[i]--;
    q[i]--;
  }
  memset(dp,0,sizeof(dp));
  rep(i,300) dp[0][i][0] = 1;
  
  rep(i,n){
    rep(j,m){
      rep(l,k+1){
        if(l+c[j]>k)continue;
      	dp[i+1][q[j]][l+c[j]]+=dp[i][p[j]][l];
        dp[i+1][q[j]][l+c[j]]%=MOD;
      }
    }
  }
  ll ans = 0;
  rep(i,300){
    ans += dp[n-1][i][k];
    ans%=MOD;
  }
  cout << ans << endl; 
  return 0;
}
0