結果
問題 | No.1749 ラムドスウイルスの感染拡大 |
ユーザー |
![]() |
提出日時 | 2021-11-19 21:56:29 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 165 ms / 2,000 ms |
コード長 | 1,052 bytes |
コンパイル時間 | 2,306 ms |
コンパイル使用メモリ | 80,992 KB |
実行使用メモリ | 56,272 KB |
最終ジャッジ日時 | 2025-01-01 17:06:42 |
合計ジャッジ時間 | 6,285 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 26 |
ソースコード
import java.io.*;import java.util.*;class Main{public static void main(String args[])throws Exception{BufferedReader bu=new BufferedReader(new InputStreamReader(System.in));StringBuilder sb=new StringBuilder();String s[]=bu.readLine().split(" ");int n=Integer.parseInt(s[0]),m=Integer.parseInt(s[1]),t=Integer.parseInt(s[2]);int i;ArrayList<Integer> g[]=new ArrayList[n];for(i=0;i<n;i++) g[i]=new ArrayList<>();for(i=0;i<m;i++){s=bu.readLine().split(" ");int u=Integer.parseInt(s[0]),v=Integer.parseInt(s[1]);g[u].add(v); g[v].add(u);}long dp[][]=new long[2][n],M=998244353; int cur=1,j;dp[0][0]=1;for(i=1;i<=t;i++){for(j=0;j<n;j++){dp[cur][j]=0;for(int x:g[j])dp[cur][j]=(dp[cur][j]+dp[cur^1][x])%M;}cur^=1;}System.out.println(dp[cur^1][0]);}}