結果

問題 No.1749 ラムドスウイルスの感染拡大
コンテスト
ユーザー 小野寺健
提出日時 2021-11-28 21:13:29
言語 Java
(openjdk 25.0.2)
コンパイル:
javac -encoding UTF8 _filename_
実行:
java -ea -Xmx700m -Xss256M -DONLINE_JUDGE=true _class_
結果
AC  
実行時間 1,736 ms / 2,000 ms
コード長 704 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 4,123 ms
コンパイル使用メモリ 82,204 KB
実行使用メモリ 48,092 KB
最終ジャッジ日時 2026-03-22 18:32:26
合計ジャッジ時間 16,718 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 26
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import java.util.Scanner;

public class No1749 {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int M = scan.nextInt();
		int T = scan.nextInt();
		int MOD = 998244353;
		int[][] v = new int[N][2];
		boolean[][] r = new boolean[N][N];
		for (int i=0; i < M; i++) {
			int s = scan.nextInt();
			int t = scan.nextInt();
			r[s][t] = true;
			r[t][s] = true;
		}
		v[0][0] = 1;
		for (int t=0; t < T; t++) {
			for (int i=0; i < N; i++) {
				v[i][(t+1) % 2] = 0;
				for (int j=0; j < N; j++) {
					if (r[i][j]) {
						v[i][(t+1) % 2] = (v[i][(t+1) % 2] + v[j][t % 2]) % MOD;
					}
				}
			}
		}
		System.out.println(v[0][T % 2]);
	}

}
0