結果

問題 No.1749 ラムドスウイルスの感染拡大
ユーザー tentententen
提出日時 2022-08-09 09:28:10
言語 Java21
(openjdk 21)
結果
AC  
実行時間 169 ms / 2,000 ms
コード長 1,805 bytes
コンパイル時間 2,339 ms
コンパイル使用メモリ 78,800 KB
実行使用メモリ 58,612 KB
最終ジャッジ日時 2023-10-19 20:24:55
合計ジャッジ時間 6,930 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 56 ms
53,408 KB
testcase_01 AC 56 ms
53,408 KB
testcase_02 AC 56 ms
53,420 KB
testcase_03 AC 55 ms
51,484 KB
testcase_04 AC 128 ms
56,116 KB
testcase_05 AC 55 ms
52,364 KB
testcase_06 AC 58 ms
52,352 KB
testcase_07 AC 58 ms
53,420 KB
testcase_08 AC 55 ms
53,420 KB
testcase_09 AC 58 ms
53,416 KB
testcase_10 AC 120 ms
57,844 KB
testcase_11 AC 120 ms
57,824 KB
testcase_12 AC 157 ms
58,140 KB
testcase_13 AC 61 ms
53,440 KB
testcase_14 AC 102 ms
54,608 KB
testcase_15 AC 122 ms
54,140 KB
testcase_16 AC 121 ms
55,992 KB
testcase_17 AC 160 ms
58,612 KB
testcase_18 AC 169 ms
58,332 KB
testcase_19 AC 166 ms
58,332 KB
testcase_20 AC 79 ms
54,844 KB
testcase_21 AC 79 ms
54,828 KB
testcase_22 AC 56 ms
53,412 KB
testcase_23 AC 56 ms
53,432 KB
testcase_24 AC 59 ms
53,416 KB
testcase_25 AC 126 ms
58,124 KB
testcase_26 AC 109 ms
57,384 KB
testcase_27 AC 103 ms
57,112 KB
testcase_28 AC 126 ms
56,256 KB
testcase_29 AC 129 ms
56,272 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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();
    }
}
0