結果

問題 No.1750 ラムドスウイルスの感染拡大-hard
ユーザー hourenhouren
提出日時 2021-11-19 21:58:57
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 985 bytes
コンパイル時間 1,957 ms
コンパイル使用メモリ 172,276 KB
実行使用メモリ 4,500 KB
最終ジャッジ日時 2023-08-30 08:24:58
合計ジャッジ時間 4,029 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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