結果

問題 No.1750 ラムドスウイルスの感染拡大-hard
ユーザー hiro71687khiro71687k
提出日時 2023-07-21 19:32:45
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,238 bytes
コンパイル時間 4,191 ms
コンパイル使用メモリ 266,584 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-21 19:46:09
合計ジャッジ時間 15,074 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 WA -
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 155 ms
4,348 KB
testcase_09 WA -
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 897 ms
4,348 KB
testcase_19 AC 868 ms
4,348 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include<atcoder/all>
using namespace atcoder;
using namespace std;
using ll=long long;
using ld=long double;
ld pie=3.141592653589793;
ll inf=922775807;
ll mod=998244353;
vector<vector<ll>>mul(vector<vector<ll>>&a,vector<vector<ll>>&b){
    vector<vector<ll>>c(a.size(),vector<ll>(b[0].size(),0));
    for (ll i = 0; i < a.size(); i++)
    {
        for (ll j = 0; j < b[0].size(); j++)
        {
            for (ll k = 0; k < a[0].size(); k++)
            {
                c[i][j]+=a[i][k]*b[k][j]%mod;
            }
        }
    }
    return c;
}
vector<vector<ll>>matpow(vector<vector<ll>>a,ll n){
    vector<vector<ll>>b(a.size(),vector<ll>(a.size(),0));
    for (ll i = 0; i < a.size(); i++)
    {
        b[i][i]=1;
    }
    while (n>0)
    {
        if (n%2)
        {
            b=mul(a,b);
            n-=1;
        }else{
            a=mul(a,a);
            n/=2;
        }
    }
    return b;
}
int main(){
    ll n,m,t;
    cin >> n >> m >> t;
    vector<vector<ll>>g(n,vector<ll>(n,0));
    for (ll i = 0; i < m; i++)
    {
        ll s,tt;
        cin >> s >> tt;
        g[s][tt]=1;
        g[tt][s]=1;
    }
    vector<vector<ll>>gg=matpow(g,t);
    ll ans=0;
    cout << gg[0][0] << endl;
}
0