結果

問題 No.1111 コード進行
ユーザー SSRSSSRS
提出日時 2020-07-10 21:37:18
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 547 ms / 2,000 ms
コード長 940 bytes
コンパイル時間 2,091 ms
コンパイル使用メモリ 174,332 KB
実行使用メモリ 218,368 KB
最終ジャッジ日時 2024-04-19 16:13:17
合計ジャッジ時間 6,203 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,376 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 4 ms
6,144 KB
testcase_06 AC 9 ms
7,936 KB
testcase_07 AC 8 ms
7,296 KB
testcase_08 AC 5 ms
5,376 KB
testcase_09 AC 6 ms
6,272 KB
testcase_10 AC 9 ms
9,856 KB
testcase_11 AC 4 ms
5,376 KB
testcase_12 AC 9 ms
7,936 KB
testcase_13 AC 6 ms
6,656 KB
testcase_14 AC 14 ms
10,368 KB
testcase_15 AC 4 ms
5,376 KB
testcase_16 AC 10 ms
8,576 KB
testcase_17 AC 9 ms
10,112 KB
testcase_18 AC 3 ms
5,376 KB
testcase_19 AC 3 ms
5,376 KB
testcase_20 AC 5 ms
5,888 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 AC 12 ms
12,288 KB
testcase_23 AC 6 ms
6,528 KB
testcase_24 AC 7 ms
7,424 KB
testcase_25 AC 15 ms
11,520 KB
testcase_26 AC 11 ms
7,680 KB
testcase_27 AC 4 ms
5,376 KB
testcase_28 AC 111 ms
110,976 KB
testcase_29 AC 54 ms
48,000 KB
testcase_30 AC 95 ms
74,368 KB
testcase_31 AC 14 ms
15,360 KB
testcase_32 AC 116 ms
67,328 KB
testcase_33 AC 101 ms
44,672 KB
testcase_34 AC 79 ms
80,768 KB
testcase_35 AC 105 ms
103,168 KB
testcase_36 AC 239 ms
109,440 KB
testcase_37 AC 71 ms
29,568 KB
testcase_38 AC 55 ms
22,656 KB
testcase_39 AC 166 ms
73,344 KB
testcase_40 AC 205 ms
100,864 KB
testcase_41 AC 136 ms
123,008 KB
testcase_42 AC 113 ms
51,712 KB
testcase_43 AC 108 ms
45,568 KB
testcase_44 AC 41 ms
26,112 KB
testcase_45 AC 104 ms
75,776 KB
testcase_46 AC 11 ms
8,576 KB
testcase_47 AC 547 ms
218,368 KB
testcase_48 AC 11 ms
8,448 KB
testcase_49 AC 11 ms
8,576 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
long long MOD = 1000000007;
int main(){
  int N, M, K;
  cin >> N >> M >> K;
  vector<vector<pair<int, int>>> E(300);
  for (int i = 0; i < M; i++){
    int P, Q, C;
    cin >> P >> Q >> C;
    P--;
    Q--;
    E[P].push_back(make_pair(C, Q));
  }
  vector<vector<vector<long long>>> dp(N, vector<vector<long long>>(300, vector<long long>(K + 1, 0)));
  for (int i = 0; i < 300; i++){
    dp[0][i][0] = 1;
  }
  for (int i = 0; i < N - 1; i++){
    for (int j = 0; j < 300; j++){
      for (int k = 0; k <= K; k++){
        for (auto P : E[j]){
          int com = P.first;
          int nxt = P.second;
          if (k + com <= K){
            dp[i + 1][nxt][k + com] += dp[i][j][k];
            dp[i + 1][nxt][k + com] %= MOD;
          }
        }
      }
    }
  }
  long long ans = 0;
  for (int i = 0; i < 300; i++){
    ans += dp[N - 1][i][K];
  }
  ans %= MOD;
  cout << ans << endl;
}
0