結果

問題 No.1750 ラムドスウイルスの感染拡大-hard
ユーザー warabi0906warabi0906
提出日時 2023-05-13 13:32:12
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 289 ms / 2,000 ms
コード長 1,021 bytes
コンパイル時間 1,899 ms
コンパイル使用メモリ 173,572 KB
実行使用メモリ 8,400 KB
最終ジャッジ日時 2023-08-19 13:30:37
合計ジャッジ時間 8,226 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 7 ms
8,160 KB
testcase_01 AC 7 ms
8,208 KB
testcase_02 AC 6 ms
8,204 KB
testcase_03 AC 7 ms
8,200 KB
testcase_04 AC 33 ms
8,272 KB
testcase_05 AC 6 ms
8,244 KB
testcase_06 AC 7 ms
8,204 KB
testcase_07 AC 6 ms
8,108 KB
testcase_08 AC 279 ms
8,064 KB
testcase_09 AC 285 ms
8,256 KB
testcase_10 AC 289 ms
8,304 KB
testcase_11 AC 281 ms
8,176 KB
testcase_12 AC 284 ms
8,240 KB
testcase_13 AC 285 ms
8,112 KB
testcase_14 AC 286 ms
8,332 KB
testcase_15 AC 284 ms
8,304 KB
testcase_16 AC 284 ms
8,272 KB
testcase_17 AC 287 ms
8,252 KB
testcase_18 AC 289 ms
8,336 KB
testcase_19 AC 286 ms
8,204 KB
testcase_20 AC 187 ms
8,260 KB
testcase_21 AC 202 ms
8,224 KB
testcase_22 AC 36 ms
8,272 KB
testcase_23 AC 247 ms
8,244 KB
testcase_24 AC 31 ms
8,180 KB
testcase_25 AC 64 ms
8,312 KB
testcase_26 AC 24 ms
8,400 KB
testcase_27 AC 7 ms
8,276 KB
testcase_28 AC 7 ms
8,260 KB
testcase_29 AC 7 ms
8,272 KB
testcase_30 AC 34 ms
8,112 KB
testcase_31 AC 34 ms
8,272 KB
testcase_32 AC 35 ms
8,128 KB
testcase_33 AC 34 ms
8,132 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
constexpr int mod=998244353;
int N,M;
vector<vector<vector<long long>>> dp(102,vector<vector<long long>>(102,vector<long long>(61,0ll)));
long long T;
int main(){
    scanf("%d%d%lld",&N,&M,&T);
    for(int i=0;i<M;i++){
        int u,v;
        scanf("%d%d",&u,&v);
        dp[u][v][0]=dp[v][u][0]=1ll;
    }
    for(int bit=1;bit<=60;bit++){
        //2^bit回の移動
        for(int k=0;k<N;k++){
            //中継地点k
            for(int i=0;i<N;i++)for(int j=0;j<N;j++){
                dp[i][j][bit]+=(dp[i][k][bit-1]*dp[k][j][bit-1])%mod;
                dp[i][j][bit]%=mod;
            }
        }
    }
    vector<long long> ans(N,0ll);//ある時点でiにいる
    ans[0]=1ll;
    for(int bit=0;bit<=60;bit++)if(T&1ll<<bit){
        vector<long long> ans_(N,0ll);
        for(int i=0;i<N;i++)for(int j=0;j<N;j++){
            ans_[j]+=(ans[i]*dp[i][j][bit])%mod;
            ans_[j]%=mod;
        }
        ans=ans_;
    }
    printf("%lld",ans.front());
}
0