結果

問題 No.2711 Connecting Lights
ユーザー tentententen
提出日時 2024-05-07 17:19:23
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,990 bytes
コンパイル時間 3,631 ms
コンパイル使用メモリ 78,732 KB
実行使用メモリ 44,516 KB
最終ジャッジ日時 2024-05-07 17:19:33
合計ジャッジ時間 9,460 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 56 ms
37,092 KB
testcase_01 AC 56 ms
37,068 KB
testcase_02 AC 56 ms
37,316 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 84 ms
39,760 KB
testcase_06 AC 57 ms
37,024 KB
testcase_07 AC 57 ms
37,316 KB
testcase_08 AC 81 ms
38,144 KB
testcase_09 AC 262 ms
42,112 KB
testcase_10 AC 87 ms
40,932 KB
testcase_11 AC 165 ms
43,856 KB
testcase_12 AC 124 ms
42,044 KB
testcase_13 AC 138 ms
42,880 KB
testcase_14 AC 68 ms
38,160 KB
testcase_15 AC 132 ms
40,780 KB
testcase_16 AC 84 ms
39,796 KB
testcase_17 AC 84 ms
40,128 KB
testcase_18 AC 90 ms
39,632 KB
testcase_19 AC 112 ms
41,508 KB
testcase_20 AC 194 ms
43,064 KB
testcase_21 AC 84 ms
39,928 KB
testcase_22 AC 58 ms
37,368 KB
testcase_23 AC 66 ms
40,064 KB
testcase_24 AC 161 ms
40,696 KB
testcase_25 AC 204 ms
40,984 KB
testcase_26 AC 1,026 ms
44,344 KB
testcase_27 AC 219 ms
44,516 KB
testcase_28 AC 350 ms
44,452 KB
testcase_29 AC 148 ms
42,624 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;
import java.util.function.*;
import java.util.stream.*;

public class Main {
    static final int MOD = 998244353;
    static int n;
    static int k;
    static int[][] dp;
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        n = sc.nextInt();
        int m = sc.nextInt();
        k = sc.nextInt();
        dp = new int[m][1 << n];
        for (int[] arr : dp) {
            Arrays.fill(arr, -1);
        }
        System.out.println(dfw(m - 1, (1 << n) - 1));
    }
    
    static int dfw(int idx, int v) {
        if (idx < 0) {
            return 1;
        }
        if (dp[idx][v] < 0) {
            dp[idx][v] = 0;
            for (int i = 1; i < (1 << n); i++) {
                if (getPop(v & i) >= k) {
                    dp[idx][v] += dfw(idx - 1, i);
                    dp[idx][v] %= MOD;
                }
            }
        }
        return dp[idx][v];
    }
    
    static int getPop(int x) {
        int pop = 0;
        while (x > 0) {
            pop += x % 2;
            x >>= 1;
        }
        return pop;
    }
}
class Scanner {
    BufferedReader br;
    StringTokenizer st = new StringTokenizer("");
    StringBuilder sb = new StringBuilder();
    
    public Scanner() {
        try {
            br = new BufferedReader(new InputStreamReader(System.in));
        } catch (Exception e) {
            
        }
    }
    
    public int nextInt() {
        return Integer.parseInt(next());
    }
    
    public long nextLong() {
        return Long.parseLong(next());
    }
    
    public double nextDouble() {
        return Double.parseDouble(next());
    }
    
    public String next() {
        try {
            while (!st.hasMoreTokens()) {
                st = new StringTokenizer(br.readLine());
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            return st.nextToken();
        }
    }
    
}
0