結果

問題 No.1142 XOR と XOR
ユーザー tentententen
提出日時 2021-12-07 09:30:28
言語 Java21
(openjdk 21)
結果
TLE  
実行時間 -
コード長 2,245 bytes
コンパイル時間 2,076 ms
コンパイル使用メモリ 74,576 KB
実行使用メモリ 64,644 KB
最終ジャッジ日時 2023-09-21 16:40:01
合計ジャッジ時間 40,389 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
49,348 KB
testcase_01 AC 46 ms
49,348 KB
testcase_02 AC 47 ms
47,196 KB
testcase_03 TLE -
testcase_04 AC 1,692 ms
58,600 KB
testcase_05 AC 1,531 ms
60,452 KB
testcase_06 AC 1,708 ms
56,692 KB
testcase_07 TLE -
testcase_08 TLE -
testcase_09 TLE -
testcase_10 TLE -
testcase_11 AC 47 ms
49,200 KB
testcase_12 AC 47 ms
49,316 KB
testcase_13 AC 46 ms
49,380 KB
testcase_14 AC 1,233 ms
56,760 KB
testcase_15 AC 1,319 ms
60,736 KB
testcase_16 AC 329 ms
57,924 KB
testcase_17 AC 1,576 ms
57,088 KB
testcase_18 AC 661 ms
59,280 KB
testcase_19 AC 1,896 ms
60,936 KB
testcase_20 AC 1,336 ms
56,628 KB
testcase_21 AC 944 ms
57,920 KB
testcase_22 AC 727 ms
60,892 KB
testcase_23 AC 1,741 ms
60,092 KB
testcase_24 AC 1,893 ms
57,216 KB
testcase_25 AC 1,395 ms
60,696 KB
testcase_26 AC 1,829 ms
58,280 KB
testcase_27 AC 1,581 ms
60,856 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;
            }
            next[x]++;
            next[x] %= MOD;
            countsA = next;
            for (int j = 0; j < 1024; j++) {
                ansA[j] += countsA[j];
                ansA[j] %= MOD;
            }
        }
        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;
            }
            next[x]++;
            next[x] %= MOD;
            countsB = next;
            for (int j = 0; j < 1024; j++) {
                ansB[j] += countsB[j];
                ansB[j] %= MOD;
            }
        }
        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