結果

問題 No.1111 コード進行
ユーザー simansiman
提出日時 2022-04-07 07:28:08
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 997 bytes
コンパイル時間 1,705 ms
コンパイル使用メモリ 104,900 KB
実行使用メモリ 216,544 KB
最終ジャッジ日時 2023-08-18 16:12:50
合計ジャッジ時間 4,390 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,384 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 3 ms
6,232 KB
testcase_06 AC 5 ms
8,060 KB
testcase_07 AC 5 ms
7,436 KB
testcase_08 AC 3 ms
4,620 KB
testcase_09 WA -
testcase_10 AC 6 ms
9,892 KB
testcase_11 AC 3 ms
4,632 KB
testcase_12 AC 6 ms
8,148 KB
testcase_13 AC 4 ms
6,876 KB
testcase_14 WA -
testcase_15 AC 3 ms
4,376 KB
testcase_16 AC 6 ms
8,712 KB
testcase_17 AC 5 ms
10,232 KB
testcase_18 AC 3 ms
4,692 KB
testcase_19 AC 3 ms
4,692 KB
testcase_20 AC 4 ms
5,916 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 5 ms
12,392 KB
testcase_23 AC 5 ms
6,300 KB
testcase_24 AC 4 ms
7,484 KB
testcase_25 AC 7 ms
11,692 KB
testcase_26 AC 5 ms
7,752 KB
testcase_27 AC 3 ms
4,796 KB
testcase_28 AC 36 ms
109,724 KB
testcase_29 AC 16 ms
46,704 KB
testcase_30 AC 26 ms
73,688 KB
testcase_31 AC 7 ms
15,212 KB
testcase_32 AC 26 ms
65,592 KB
testcase_33 AC 23 ms
44,168 KB
testcase_34 AC 25 ms
79,468 KB
testcase_35 AC 32 ms
100,656 KB
testcase_36 AC 62 ms
108,368 KB
testcase_37 AC 18 ms
28,224 KB
testcase_38 AC 14 ms
21,740 KB
testcase_39 AC 37 ms
72,600 KB
testcase_40 AC 48 ms
99,056 KB
testcase_41 AC 39 ms
120,984 KB
testcase_42 AC 29 ms
50,496 KB
testcase_43 AC 26 ms
44,580 KB
testcase_44 AC 11 ms
25,272 KB
testcase_45 AC 30 ms
74,268 KB
testcase_46 AC 3 ms
4,380 KB
testcase_47 AC 173 ms
216,544 KB
testcase_48 AC 3 ms
4,376 KB
testcase_49 AC 3 ms
4,380 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;

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

  int P[M];
  int Q[M];
  int C[M];
  ll dp[N + 1][301][K + 1];
  memset(dp, 0, sizeof(dp));

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

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

  for (int i = 0; i < N - 2; ++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 - 2][i][K];
    ans %= MOD;
  }

  cout << ans << endl;

  return 0;
}
0