結果

問題 No.1111 コード進行
ユーザー Shun_PIShun_PI
提出日時 2020-07-10 21:45:19
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 290 ms / 2,000 ms
コード長 1,148 bytes
コンパイル時間 1,787 ms
コンパイル使用メモリ 170,788 KB
実行使用メモリ 218,368 KB
最終ジャッジ日時 2024-04-19 16:37:00
合計ジャッジ時間 4,885 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 3 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 5 ms
6,144 KB
testcase_06 AC 6 ms
7,808 KB
testcase_07 AC 6 ms
7,168 KB
testcase_08 AC 3 ms
5,376 KB
testcase_09 AC 5 ms
6,272 KB
testcase_10 AC 7 ms
9,856 KB
testcase_11 AC 4 ms
5,376 KB
testcase_12 AC 7 ms
7,808 KB
testcase_13 AC 4 ms
6,528 KB
testcase_14 AC 10 ms
10,368 KB
testcase_15 AC 3 ms
5,376 KB
testcase_16 AC 7 ms
8,576 KB
testcase_17 AC 7 ms
9,984 KB
testcase_18 AC 4 ms
5,376 KB
testcase_19 AC 3 ms
5,376 KB
testcase_20 AC 4 ms
5,632 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 AC 8 ms
12,160 KB
testcase_23 AC 4 ms
6,272 KB
testcase_24 AC 6 ms
7,296 KB
testcase_25 AC 11 ms
11,392 KB
testcase_26 AC 7 ms
7,680 KB
testcase_27 AC 3 ms
5,376 KB
testcase_28 AC 99 ms
110,976 KB
testcase_29 AC 44 ms
48,000 KB
testcase_30 AC 70 ms
74,240 KB
testcase_31 AC 12 ms
15,488 KB
testcase_32 AC 73 ms
67,200 KB
testcase_33 AC 52 ms
44,416 KB
testcase_34 AC 66 ms
80,640 KB
testcase_35 AC 87 ms
103,296 KB
testcase_36 AC 136 ms
109,440 KB
testcase_37 AC 41 ms
29,568 KB
testcase_38 AC 31 ms
22,656 KB
testcase_39 AC 88 ms
73,344 KB
testcase_40 AC 117 ms
100,864 KB
testcase_41 AC 108 ms
123,008 KB
testcase_42 AC 70 ms
51,712 KB
testcase_43 AC 58 ms
45,568 KB
testcase_44 AC 29 ms
26,112 KB
testcase_45 AC 75 ms
75,776 KB
testcase_46 AC 11 ms
8,448 KB
testcase_47 AC 290 ms
218,368 KB
testcase_48 AC 11 ms
8,320 KB
testcase_49 AC 11 ms
8,576 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<int, int>;
using PL = pair<lint, lint>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
void yes(bool expr) {
  cout << (expr ? "Yes" : "No") << "\n";
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    lint N, M, K;
    cin >> N >> M >> K;
    vector<lint> P(M);
    vector<lint> Q(M);
    vector<lint> C(M);
    REP(i, M) {
        cin >> P[i] >> Q[i] >> C[i];
        P[i]--; Q[i]--;
    }
    vector<vector<vector<lint>>> dp(N, vector<vector<lint>>(300, vector<lint>(K+1)));
    REP(i, 300) dp[0][i][0] = 1;
    REP(i, N-1) REP(j, M) IREP(k, K+1) {
        if(k + C[j] <= K) dp[i+1][Q[j]][k+C[j]] = (dp[i+1][Q[j]][k+C[j]] + dp[i][P[j]][k]) % MOD;
    }
    lint ans = 0;
    REP(i, 300) ans = (ans + dp[N-1][i][K]) % MOD;
    cout << ans << endl;
}
0