結果

問題 No.1112 冥界の音楽
ユーザー butsurizukibutsurizuki
提出日時 2021-12-18 20:06:07
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 8 ms / 2,000 ms
コード長 1,012 bytes
コンパイル時間 4,578 ms
コンパイル使用メモリ 250,724 KB
実行使用メモリ 4,376 KB
最終ジャッジ日時 2023-10-13 18:03:16
合計ジャッジ時間 4,674 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>
#define mod 1000000007

using namespace std;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int k,m;
  long long n;
  cin >> k >> m >> n;
  n-=3;
  vector<vector<long long>> g(k*k,vector<long long>(k*k,0));
  vector<long long> v(k*k,0);
  for(int i=0;i<m;i++){
    int p,q,r;
    cin >> p >> q >> r;
    p--;q--;r--;
    if(p==0){v[q*k+r]++;}
    g[p*k+q][q*k+r]++;
  }
  for(int i=0;i<60;i++){
    if(n&(1ll<<i)){
      vector<long long> nv(k*k,0);
      for(int p=0;p<k*k;p++){
        for(int q=0;q<k*k;q++){
          nv[q]+=v[p]*g[p][q];
          nv[q]%=mod;
        }
      }
      v.swap(nv);
    }
    vector<vector<long long>> ng(k*k,vector<long long>(k*k,0));
    for(int p=0;p<k*k;p++){
      for(int q=0;q<k*k;q++){
        for(int r=0;r<k*k;r++){
          ng[p][r]+=g[p][q]*g[q][r];
          ng[p][r]%=mod;
        }
      }
    }
    g.swap(ng);
  }
  long long res=0;
  for(int i=0;i<k;i++){res+=v[k*i];res%=mod;}
  cout << res << '\n';
  return 0;
}
0