結果

問題 No.1189 Sum is XOR
ユーザー tentententen
提出日時 2023-04-25 09:16:15
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 2,287 bytes
コンパイル時間 2,442 ms
コンパイル使用メモリ 90,044 KB
実行使用メモリ 57,972 KB
最終ジャッジ日時 2024-04-26 16:38:22
合計ジャッジ時間 7,384 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 52 ms
50,468 KB
testcase_04 AC 53 ms
50,460 KB
testcase_05 AC 50 ms
50,416 KB
testcase_06 AC 49 ms
50,372 KB
testcase_07 AC 50 ms
50,560 KB
testcase_08 AC 51 ms
50,492 KB
testcase_09 AC 52 ms
50,224 KB
testcase_10 AC 52 ms
50,480 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 62 ms
50,840 KB
testcase_22 AC 59 ms
50,340 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class Main {
    static final int MOD = 1000000007;
    static long[][][] dp;
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        int n = sc.nextInt();
        int k = sc.nextInt();
        if (k > 10) {
            System.out.println(0);
            return;
        }
        long[][] dp = new long[k][1 << 10];
        for (int i = 0; i < n; i++) {
            dp[0][sc.nextInt()]++;
        }
        for (int i = 1; i < k; i++) {
            for (int j = 1; j < (1 << 10); j++) {
                for (int s = j + 1; s < (1 << 10); s++) {
                    if ((j & s) == 0) {
                        dp[i][j ^ s] += dp[i - 1][j] * dp[0][s] % MOD;
                        dp[i][j ^ s] %= MOD;
                    }
                }
            }
        }
        long ans = 0;
        for (int i = 1; i < (1 << 10); i++) {
            ans += dp[k - 1][i];
            ans %= MOD;
        }
        System.out.println(ans);
    }
}
class Utilities {
    static String arrayToLineString(Object[] arr) {
        return Arrays.stream(arr).map(x -> x.toString()).collect(Collectors.joining("\n"));
    }
    
    static String arrayToLineString(int[] arr) {
        return String.join("\n", Arrays.stream(arr).mapToObj(String::valueOf).toArray(String[]::new));
    }
}
class Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    StringBuilder sb = new StringBuilder();
    
    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 int[] nextIntArray() throws Exception {
        return Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
    }
    
    public String next() throws Exception {
        while (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
    
}
0