結果

問題 No.1111 コード進行
ユーザー どららどらら
提出日時 2020-07-10 22:45:09
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 295 ms / 2,000 ms
コード長 923 bytes
コンパイル時間 1,439 ms
コンパイル使用メモリ 168,708 KB
実行使用メモリ 218,496 KB
最終ジャッジ日時 2024-04-19 17:57:25
合計ジャッジ時間 4,364 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 1 ms
6,944 KB
testcase_03 AC 1 ms
6,940 KB
testcase_04 AC 1 ms
6,940 KB
testcase_05 AC 3 ms
6,940 KB
testcase_06 AC 5 ms
7,296 KB
testcase_07 AC 5 ms
7,040 KB
testcase_08 AC 3 ms
6,940 KB
testcase_09 AC 4 ms
6,940 KB
testcase_10 AC 7 ms
9,088 KB
testcase_11 AC 2 ms
6,940 KB
testcase_12 AC 6 ms
7,296 KB
testcase_13 AC 4 ms
6,940 KB
testcase_14 AC 9 ms
9,600 KB
testcase_15 AC 3 ms
6,944 KB
testcase_16 AC 6 ms
7,936 KB
testcase_17 AC 7 ms
9,728 KB
testcase_18 AC 2 ms
6,944 KB
testcase_19 AC 2 ms
6,940 KB
testcase_20 AC 3 ms
6,944 KB
testcase_21 AC 2 ms
6,940 KB
testcase_22 AC 9 ms
11,392 KB
testcase_23 AC 4 ms
6,944 KB
testcase_24 AC 5 ms
6,944 KB
testcase_25 AC 11 ms
11,008 KB
testcase_26 AC 6 ms
7,680 KB
testcase_27 AC 3 ms
6,940 KB
testcase_28 AC 105 ms
110,208 KB
testcase_29 AC 45 ms
47,616 KB
testcase_30 AC 80 ms
73,984 KB
testcase_31 AC 12 ms
14,720 KB
testcase_32 AC 76 ms
66,944 KB
testcase_33 AC 61 ms
44,032 KB
testcase_34 AC 77 ms
79,872 KB
testcase_35 AC 99 ms
102,400 KB
testcase_36 AC 146 ms
109,440 KB
testcase_37 AC 37 ms
29,184 KB
testcase_38 AC 28 ms
22,272 KB
testcase_39 AC 100 ms
72,832 KB
testcase_40 AC 131 ms
100,352 KB
testcase_41 AC 126 ms
122,368 KB
testcase_42 AC 65 ms
51,328 KB
testcase_43 AC 61 ms
45,056 KB
testcase_44 AC 27 ms
25,600 KB
testcase_45 AC 80 ms
75,264 KB
testcase_46 AC 4 ms
6,944 KB
testcase_47 AC 295 ms
218,496 KB
testcase_48 AC 5 ms
6,940 KB
testcase_49 AC 4 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

static const ll MOD = 1000000007;

ll dp[305][305][305];

int main(){
  int N, M, K;
  cin >> N >> M >> K;

  vector<vector<int>> v;
  rep(i,M){
    int p, q, c;
    cin >> p >> q >> c;
    v.push_back({p,q,c});
  }

  rep(i,305) dp[0][0][i] = 1;
  
  rep(i,N-1){
    rep(j,K+1){
      rep(k,v.size()){
        int p = v[k][0];
        int q = v[k][1];
        int c = v[k][2];
        if(j+c <= K){
          dp[i+1][j+c][q] += dp[i][j][p];
          dp[i+1][j+c][q] %= MOD;
        }
      }
    }
  }
  
  ll ret = 0;
  rep(i,305){
    ret += dp[N-1][K][i];
    ret %= MOD;
  }
  cout << ret << endl;
  
  return 0;
}

0