結果

問題 No.1142 XOR と XOR
ユーザー tentententen
提出日時 2021-12-07 09:43:04
言語 Java21
(openjdk 21)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 2,245 bytes
コンパイル時間 3,372 ms
コンパイル使用メモリ 77,756 KB
実行使用メモリ 61,416 KB
最終ジャッジ日時 2024-04-25 16:51:28
合計ジャッジ時間 37,827 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 50 ms
50,492 KB
testcase_01 AC 51 ms
50,316 KB
testcase_02 AC 52 ms
50,352 KB
testcase_03 AC 1,904 ms
61,416 KB
testcase_04 AC 1,685 ms
59,336 KB
testcase_05 AC 1,425 ms
59,008 KB
testcase_06 AC 1,798 ms
57,464 KB
testcase_07 TLE -
testcase_08 TLE -
testcase_09 TLE -
testcase_10 TLE -
testcase_11 AC 51 ms
50,388 KB
testcase_12 AC 51 ms
50,492 KB
testcase_13 AC 51 ms
50,196 KB
testcase_14 AC 1,267 ms
57,520 KB
testcase_15 AC 1,217 ms
57,656 KB
testcase_16 AC 242 ms
55,576 KB
testcase_17 AC 1,670 ms
57,124 KB
testcase_18 AC 599 ms
57,024 KB
testcase_19 AC 1,781 ms
59,360 KB
testcase_20 AC 1,178 ms
57,304 KB
testcase_21 AC 891 ms
57,400 KB
testcase_22 AC 583 ms
57,268 KB
testcase_23 AC 1,687 ms
60,940 KB
testcase_24 AC 1,906 ms
57,436 KB
testcase_25 AC 1,205 ms
57,520 KB
testcase_26 AC 1,764 ms
59,140 KB
testcase_27 AC 1,533 ms
59,508 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class Main {
    static final int MOD = 1000000007;
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        int n = sc.nextInt();
        int m = sc.nextInt();
        int k = sc.nextInt();
        int[] countsA = new int[1024];
        int[] ansA = new int[1024];
        for (int i = 0; i < n; i++) {
            int[] next = new int[1024];
            int x = sc.nextInt();
            for (int j = 0; j < 1024; j++) {
                next[j ^ x] += countsA[j];
                next[j ^ x] %= MOD;
                ansA[j ^ x] += countsA[j];
                ansA[j ^ x] %= MOD;
            }
            next[x]++;
            next[x] %= MOD;
            ansA[x]++;
            ansA[x] %= MOD;
            countsA = next;
        }
        int[] countsB = new int[1024];
        int[] ansB = new int[1024];
        for (int i = 0; i < m; i++) {
            int[] next = new int[1024];
            int x = sc.nextInt();
            for (int j = 0; j < 1024; j++) {
                next[j ^ x] += countsB[j];
                next[j ^ x] %= MOD;
                ansB[j ^ x] += countsB[j];
                ansB[j ^ x] %= MOD;
            }
            next[x]++;
            next[x] %= MOD;
            ansB[x]++;
            ansB[x] %= MOD;
            countsB = next;
        }
        long ans = 0;
        for (int i = 0; i < 1024; i++) {
            ans += (long)ansA[i] * ansB[i ^ k];
            ans %= MOD;
        }
        System.out.println(ans);
    }
}
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 {
        if (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
}
0