結果

問題 No.1112 冥界の音楽
ユーザー erbowlerbowl
提出日時 2020-07-13 19:22:06
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,045 bytes
コンパイル時間 2,521 ms
コンパイル使用メモリ 205,104 KB
実行使用メモリ 6,528 KB
最終ジャッジ日時 2024-04-25 12:16:28
合計ジャッジ時間 3,030 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 2 ms
5,248 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 WA -
testcase_10 AC 2 ms
5,376 KB
testcase_11 WA -
testcase_12 AC 1 ms
5,376 KB
testcase_13 AC 1 ms
5,376 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 2 ms
5,376 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 1 ms
5,376 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 3 ms
6,272 KB
testcase_25 AC 3 ms
6,400 KB
testcase_26 AC 3 ms
6,144 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 3 ms
6,272 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 3 ms
5,760 KB
testcase_35 AC 3 ms
6,272 KB
testcase_36 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

typedef long long ll;
typedef long double ld;
#include <bits/stdc++.h>
using namespace std;
const ll MOD = 1e9+7;
vector<vector<ll>> edges(40,vector<ll>(40,0));
ll k;
vector<vector<ll>> rui(ll x){
    if(x==1) return edges;
    auto x1 = edges;
    auto x2 = edges;
    if(x%2==1){
        x2 = rui(x-1);
    }else{
        x1 = x2 = rui(x/2);
    }
    vector<vector<ll>> ans(k*k,vector<ll>(k*k,0));
    for (ll i = 0; i < k*k; i++) {
        for (ll j = 0; j < k*k; j++) {
            for (ll ii = 0; ii < k*k; ii++) {
                ans[i][j] += x1[i][ii]*x2[ii][j]%MOD;
                ans[i][j] %= MOD;
            }
        }
    }
    return ans;
}
int main() {
    ll m,n;
    std::cin >> k>>m>>n;
    
    
    for (int i = 0; i < m; i++) {
        ll p,q,r;
        std::cin >> p>>q>>r;
        p--;q--;r--;
        
        edges[k*p+q][k*q+r] = 1;
    }

    auto x3 = rui(n-2);
    ll ans = 0;
    
    for (int j = 0; j < k; j++) {
        ans += x3[j][k*j]%MOD;
        ans %= MOD;
    }
    
    std::cout << ans << std::endl;
}
0