結果

問題 No.1111 コード進行
ユーザー kk
提出日時 2020-09-04 23:16:03
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 443 ms / 2,000 ms
コード長 900 bytes
コンパイル時間 1,953 ms
コンパイル使用メモリ 202,824 KB
実行使用メモリ 215,860 KB
最終ジャッジ日時 2023-08-17 20:43:16
合計ジャッジ時間 9,712 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
6,220 KB
testcase_01 AC 5 ms
5,580 KB
testcase_02 AC 4 ms
4,856 KB
testcase_03 AC 4 ms
4,840 KB
testcase_04 AC 4 ms
4,804 KB
testcase_05 AC 6 ms
5,528 KB
testcase_06 AC 12 ms
9,092 KB
testcase_07 AC 16 ms
12,620 KB
testcase_08 AC 14 ms
11,852 KB
testcase_09 AC 7 ms
6,256 KB
testcase_10 AC 21 ms
16,260 KB
testcase_11 AC 11 ms
10,436 KB
testcase_12 AC 12 ms
9,024 KB
testcase_13 AC 10 ms
8,348 KB
testcase_14 AC 18 ms
12,172 KB
testcase_15 AC 15 ms
14,780 KB
testcase_16 AC 14 ms
9,736 KB
testcase_17 AC 21 ms
16,152 KB
testcase_18 AC 13 ms
12,064 KB
testcase_19 AC 4 ms
4,824 KB
testcase_20 AC 7 ms
6,296 KB
testcase_21 AC 14 ms
13,356 KB
testcase_22 AC 22 ms
15,464 KB
testcase_23 AC 14 ms
11,212 KB
testcase_24 AC 13 ms
10,048 KB
testcase_25 AC 25 ms
16,368 KB
testcase_26 AC 19 ms
14,028 KB
testcase_27 AC 5 ms
5,700 KB
testcase_28 AC 214 ms
130,104 KB
testcase_29 AC 174 ms
124,492 KB
testcase_30 AC 146 ms
86,332 KB
testcase_31 AC 30 ms
20,344 KB
testcase_32 AC 244 ms
162,616 KB
testcase_33 AC 101 ms
55,736 KB
testcase_34 AC 171 ms
109,576 KB
testcase_35 AC 280 ms
190,376 KB
testcase_36 AC 242 ms
131,700 KB
testcase_37 AC 180 ms
121,568 KB
testcase_38 AC 132 ms
87,612 KB
testcase_39 AC 170 ms
81,984 KB
testcase_40 AC 241 ms
138,644 KB
testcase_41 AC 247 ms
152,808 KB
testcase_42 AC 196 ms
130,104 KB
testcase_43 AC 139 ms
84,108 KB
testcase_44 AC 104 ms
75,656 KB
testcase_45 AC 195 ms
127,928 KB
testcase_46 AC 275 ms
215,488 KB
testcase_47 AC 443 ms
215,760 KB
testcase_48 AC 276 ms
215,536 KB
testcase_49 AC 275 ms
215,860 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for (int i=(int)(b); i<(int)(e); i++)
#define ALL(x) (x).begin(), (x).end()

const double PI = acos(-1);
const long long MOD = 1e9 + 7;

int n, m, K;
vector<pair<int, int> > edges[301];
long long dp[301][301][301];

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  cin >> n >> m >> K;

  for (int i = 1; i <= 300; i++)
    edges[0].emplace_back(i, 0);
  
  REP (i, m) {
    int p, q, c;
    cin >> p >> q >> c;
    edges[p].emplace_back(q, c);
  }

  dp[0][0][0] = 1;

  REP (i, n) {
    REP (j, 301) REP (k, 301) {
      for (auto &pr: edges[j]) {
        if (k + pr.second <= K)
          (dp[i+1][pr.first][k + pr.second] += dp[i][j][k]) %= MOD;
      }
    }
  }

  long long ret = 0;
  REP (i, 301) (ret += dp[n][i][K]) %= MOD;
  cout << ret << endl;
  
  return 0;
}
0