結果

問題 No.1111 コード進行
ユーザー simansiman
提出日時 2022-04-07 07:37:02
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
AC  
実行時間 144 ms / 2,000 ms
コード長 983 bytes
コンパイル時間 2,096 ms
コンパイル使用メモリ 101,644 KB
実行使用メモリ 216,552 KB
最終ジャッジ日時 2023-08-18 16:14:12
合計ジャッジ時間 7,578 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
216,512 KB
testcase_01 AC 80 ms
216,520 KB
testcase_02 AC 81 ms
216,392 KB
testcase_03 AC 81 ms
216,432 KB
testcase_04 AC 80 ms
216,472 KB
testcase_05 AC 79 ms
216,472 KB
testcase_06 AC 80 ms
216,512 KB
testcase_07 AC 85 ms
216,548 KB
testcase_08 AC 62 ms
216,476 KB
testcase_09 AC 63 ms
216,516 KB
testcase_10 AC 62 ms
216,436 KB
testcase_11 AC 61 ms
216,516 KB
testcase_12 AC 62 ms
216,384 KB
testcase_13 AC 61 ms
216,460 KB
testcase_14 AC 63 ms
216,532 KB
testcase_15 AC 61 ms
216,480 KB
testcase_16 AC 62 ms
216,540 KB
testcase_17 AC 62 ms
216,376 KB
testcase_18 AC 62 ms
216,460 KB
testcase_19 AC 62 ms
216,380 KB
testcase_20 AC 62 ms
216,480 KB
testcase_21 AC 61 ms
216,512 KB
testcase_22 AC 63 ms
216,508 KB
testcase_23 AC 62 ms
216,468 KB
testcase_24 AC 62 ms
216,524 KB
testcase_25 AC 62 ms
216,392 KB
testcase_26 AC 63 ms
216,520 KB
testcase_27 AC 61 ms
216,524 KB
testcase_28 AC 61 ms
216,384 KB
testcase_29 AC 64 ms
216,468 KB
testcase_30 AC 65 ms
216,380 KB
testcase_31 AC 61 ms
216,532 KB
testcase_32 AC 68 ms
216,540 KB
testcase_33 AC 71 ms
216,472 KB
testcase_34 AC 61 ms
216,396 KB
testcase_35 AC 62 ms
216,480 KB
testcase_36 AC 94 ms
216,440 KB
testcase_37 AC 77 ms
216,392 KB
testcase_38 AC 71 ms
216,504 KB
testcase_39 AC 79 ms
216,516 KB
testcase_40 AC 85 ms
216,380 KB
testcase_41 AC 67 ms
216,512 KB
testcase_42 AC 78 ms
216,392 KB
testcase_43 AC 76 ms
216,508 KB
testcase_44 AC 66 ms
216,552 KB
testcase_45 AC 70 ms
216,552 KB
testcase_46 AC 64 ms
216,552 KB
testcase_47 AC 144 ms
216,384 KB
testcase_48 AC 64 ms
216,540 KB
testcase_49 AC 64 ms
216,464 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cassert>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <climits>
#include <map>
#include <queue>
#include <set>
#include <cstring>
#include <vector>

using namespace std;
typedef long long ll;

const ll MOD = 1000000007;
ll dp[301][301][301];

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

  int P[M];
  int Q[M];
  int C[M];
  memset(dp, 0, sizeof(dp));

  for (int i = 0; i < M; ++i) {
    cin >> P[i] >> Q[i] >> C[i];

    dp[2][Q[i]][C[i]]++;
  }

  for (int i = 2; i < N; ++i) {
    for (int j = 0; j < M; ++j) {
      for (int k = K - C[j]; k >= 0; --k) {
        int nk = k + C[j];

        // fprintf(stderr, "i: %d, (%d -> %d) k: %d, cnt: %lld\n", i, P[j], Q[j], nk, dp[i][P[j]][k]);
        dp[i + 1][Q[j]][nk] += dp[i][P[j]][k];
        dp[i + 1][Q[j]][nk] %= MOD;
      }
    }
  }

  ll ans = 0;

  for (int i = 0; i <= 300; ++i) {
    ans += dp[N][i][K];
    ans %= MOD;
  }

  cout << ans << endl;

  return 0;
}
0