結果

問題 No.1750 ラムドスウイルスの感染拡大-hard
ユーザー hourenhouren
提出日時 2021-11-19 22:01:12
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 378 ms / 2,000 ms
コード長 985 bytes
コンパイル時間 2,974 ms
コンパイル使用メモリ 171,316 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-30 08:28:42
合計ジャッジ時間 7,356 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 9 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 63 ms
4,384 KB
testcase_09 AC 63 ms
4,384 KB
testcase_10 AC 64 ms
4,376 KB
testcase_11 AC 48 ms
4,376 KB
testcase_12 AC 68 ms
4,380 KB
testcase_13 AC 64 ms
4,384 KB
testcase_14 AC 350 ms
4,380 KB
testcase_15 AC 357 ms
4,376 KB
testcase_16 AC 357 ms
4,380 KB
testcase_17 AC 364 ms
4,376 KB
testcase_18 AC 378 ms
4,380 KB
testcase_19 AC 361 ms
4,380 KB
testcase_20 AC 247 ms
4,380 KB
testcase_21 AC 287 ms
4,380 KB
testcase_22 AC 49 ms
4,380 KB
testcase_23 AC 342 ms
4,380 KB
testcase_24 AC 39 ms
4,384 KB
testcase_25 AC 92 ms
4,380 KB
testcase_26 AC 29 ms
4,376 KB
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 3 ms
4,376 KB
testcase_29 AC 2 ms
4,380 KB
testcase_30 AC 49 ms
4,380 KB
testcase_31 AC 46 ms
4,380 KB
testcase_32 AC 45 ms
4,384 KB
testcase_33 AC 43 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 998244353;
using P = pair<int,int>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(x) (x).begin(),(x).end()
template <typename T>
vector<vector<T>> MatrixProduct(vector<vector<T>> vec1, vector<vector<T>> vec2){
    int N = vec1.size(), M = vec2[0].size(), L = vec2.size();
    vector<vector<T>> res(N,vector<T>(M,0));
    rep(i,N) rep(j,M) rep(k,L){
        res[i][j] += vec1[i][k] * vec2[k][j];
        res[i][j] %= MOD;
    }
    return res;
}
int main(){
    ll n,m,t;
    cin >> n >> m >> t;
    vector<vector<ll>> mult(n,vector<ll>(n,0));
    rep(i,m){
        int a,b;
        cin >> a >> b;
        mult[a][b] = mult[b][a] = 1;
    }
    vector<vector<ll>> a(1,vector<ll>(n,0));
    a[0][0] = 1;
    while(t){
        if(t&1){
            a = MatrixProduct(mult,a);
        }
        mult = MatrixProduct(mult,mult);
        t >>= 1;
    }
    cout << a[0][0] << endl;
    return 0;
}
0