結果

問題 No.1750 ラムドスウイルスの感染拡大-hard
ユーザー 👑 rin204rin204
提出日時 2022-01-23 07:29:35
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 247 ms / 2,000 ms
コード長 915 bytes
コンパイル時間 2,413 ms
コンパイル使用メモリ 208,308 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-19 10:29:16
合計ジャッジ時間 7,025 ms
ジャッジサーバーID
(参考情報)
judge10 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 7 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 42 ms
4,380 KB
testcase_09 AC 43 ms
4,380 KB
testcase_10 AC 43 ms
4,380 KB
testcase_11 AC 34 ms
4,376 KB
testcase_12 AC 43 ms
4,380 KB
testcase_13 AC 43 ms
4,380 KB
testcase_14 AC 247 ms
4,380 KB
testcase_15 AC 240 ms
4,384 KB
testcase_16 AC 241 ms
4,380 KB
testcase_17 AC 245 ms
4,380 KB
testcase_18 AC 243 ms
4,380 KB
testcase_19 AC 242 ms
4,376 KB
testcase_20 AC 174 ms
4,380 KB
testcase_21 AC 190 ms
4,380 KB
testcase_22 AC 32 ms
4,380 KB
testcase_23 AC 214 ms
4,376 KB
testcase_24 AC 28 ms
4,376 KB
testcase_25 AC 61 ms
4,380 KB
testcase_26 AC 20 ms
4,384 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 2 ms
4,376 KB
testcase_29 AC 2 ms
4,376 KB
testcase_30 AC 31 ms
4,376 KB
testcase_31 AC 30 ms
4,376 KB
testcase_32 AC 31 ms
4,376 KB
testcase_33 AC 31 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
const long long MOD = 998244353;

int main(void){
    int n, m;
    long long T;
    cin >> n >> m >> T;
    vector<vector<long long>> A(n, vector<long long>(n, 0));
    vector<long long> B(n, 0);
    B[0] = 1;
    int s, t;
    while(m--){
        cin >> s >> t;
        A[s][t] = 1;
        A[t][s] = 1;
    }
    while(T){
        if(T & 1){
            vector<long long> C(n, 0);
            for(int i = 0; i < n; i++) for(int j = 0; j < n; j++){
                C[i] = (C[i] + A[i][j] * B[j]) % MOD;
            }
            B = C;
        }
        T >>= 1;
        vector<vector<long long>> C(n, vector<long long>(n, 0));
        for(int i = 0; i < n; i++) for(int j = 0; j < n; j++){
            for(int k = 0; k < n; k++){
                C[i][j] = (C[i][j] + A[i][k] * A[k][j]) % MOD;
            }
        }
        A = C;
    }
    cout << B[0] << "\n";
}
0