結果

問題 No.1112 冥界の音楽
ユーザー trineutrontrineutron
提出日時 2019-11-01 02:27:58
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 894 bytes
コンパイル時間 1,636 ms
コンパイル使用メモリ 176,128 KB
実行使用メモリ 50,044 KB
最終ジャッジ日時 2023-10-13 00:17:16
合計ジャッジ時間 5,099 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,352 KB
testcase_01 AC 1 ms
4,352 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 1 ms
4,348 KB
testcase_05 AC 1 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,352 KB
testcase_08 AC 1 ms
4,352 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 1 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 1 ms
4,348 KB
testcase_14 AC 86 ms
49,620 KB
testcase_15 AC 6 ms
5,380 KB
testcase_16 AC 15 ms
10,384 KB
testcase_17 AC 34 ms
20,316 KB
testcase_18 AC 45 ms
25,272 KB
testcase_19 AC 4 ms
4,352 KB
testcase_20 AC 42 ms
26,304 KB
testcase_21 AC 85 ms
50,044 KB
testcase_22 AC 26 ms
15,960 KB
testcase_23 AC 4 ms
4,548 KB
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
testcase_34 RE -
testcase_35 RE -
testcase_36 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
    const long mod = 1000000007;
    int k, m, n;
    cin >> k >> m >> n;
    vector<vector<int>> next(k * k);
    vector<vector<vector<long>>> dp(n - 1, vector<vector<long>>(k, vector<long>(k)));
    for (int i = 0; i < m; i++) {
        int p, q, r;
        cin >> p >> q >> r;
        p--; q--; r--;
        next.at(p * k + q).push_back(r);
        if (p == 0) dp[0][p][q] = 1;
    }
    for (int i = 1; i < n - 1; i++) {
        for (int p = 0; p < k; p++) {
            for (int q = 0; q < k; q++) {
                for (auto r : next.at(p * k + q)) {
                    dp[i][q][r] += dp[i - 1][p][q];
                    dp[i][q][r] %= mod;
                }
            }
        }
    }
    long ans = 0;
    for (int i = 0; i < k; i++) {
        ans += dp[n - 2][i][0];
        ans %= mod;
    }
    cout << ans << endl;
}
0