結果
| 問題 | No.1749 ラムドスウイルスの感染拡大 |
| コンテスト | |
| ユーザー |
tenten
|
| 提出日時 | 2022-08-09 09:28:10 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 148 ms / 2,000 ms |
| コード長 | 1,805 bytes |
| 記録 | |
| コンパイル時間 | 2,241 ms |
| コンパイル使用メモリ | 78,916 KB |
| 実行使用メモリ | 55,696 KB |
| 最終ジャッジ日時 | 2024-09-19 16:29:45 |
| 合計ジャッジ時間 | 5,378 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 26 |
ソースコード
import java.io.*;
import java.util.*;
public class Main {
static final int MOD = 998244353;
public static void main(String[] args) throws Exception {
Scanner sc = new Scanner();
int n = sc.nextInt();
int m = sc.nextInt();
int t = sc.nextInt();
ArrayList<ArrayList<Integer>> graph = new ArrayList<>();
for (int i = 0; i < n; i++) {
graph.add(new ArrayList<>());
}
for (int i = 0; i < m; i++) {
int a = sc.nextInt();
int b = sc.nextInt();
graph.get(a).add(b);
graph.get(b).add(a);
}
int[] current = new int[n];
current[0] = 1;
int[] next = new int[n];
while (t-- > 0) {
for (int i = 0; i < n; i++) {
for (int x : graph.get(i)) {
next[i] += current[x];
next[i] %= MOD;
}
}
int[] tmp = current;
current = next;
next = tmp;
Arrays.fill(next, 0);
}
System.out.println(current[0]);
}
}
class Scanner {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer("");
public Scanner() throws Exception {
}
public int nextInt() throws Exception {
return Integer.parseInt(next());
}
public long nextLong() throws Exception {
return Long.parseLong(next());
}
public double nextDouble() throws Exception {
return Double.parseDouble(next());
}
public String next() throws Exception {
while (!st.hasMoreTokens()) {
st = new StringTokenizer(br.readLine());
}
return st.nextToken();
}
}
tenten