結果

問題 No.1112 冥界の音楽
ユーザー trineutrontrineutron
提出日時 2019-10-12 22:09:40
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 839 bytes
コンパイル時間 1,594 ms
コンパイル使用メモリ 170,276 KB
実行使用メモリ 27,124 KB
最終ジャッジ日時 2023-08-27 06:07:38
合計ジャッジ時間 5,195 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 33 ms
26,908 KB
testcase_15 AC 3 ms
4,376 KB
testcase_16 AC 3 ms
4,380 KB
testcase_17 AC 14 ms
12,104 KB
testcase_18 AC 16 ms
14,732 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 14 ms
12,392 KB
testcase_21 AC 33 ms
27,124 KB
testcase_22 AC 11 ms
9,960 KB
testcase_23 AC 3 ms
4,380 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);
    long dp[n - 1][k][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