結果

問題 No.1142 XOR と XOR
ユーザー ks2mks2m
提出日時 2020-07-31 22:55:16
言語 Java21
(openjdk 21)
結果
TLE  
実行時間 -
コード長 1,447 bytes
コンパイル時間 3,399 ms
コンパイル使用メモリ 74,572 KB
実行使用メモリ 92,580 KB
最終ジャッジ日時 2023-09-21 01:41:24
合計ジャッジ時間 8,549 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
49,468 KB
testcase_01 AC 43 ms
49,256 KB
testcase_02 AC 46 ms
49,428 KB
testcase_03 AC 952 ms
89,896 KB
testcase_04 TLE -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;

public class Main {
	static int mod = 1000000007;
	static int mx = 1024;

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int n = Integer.parseInt(sa[0]);
		int m = Integer.parseInt(sa[1]);
		int k = Integer.parseInt(sa[2]);
		sa = br.readLine().split(" ");
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(sa[i]);
		}
		sa = br.readLine().split(" ");
		int[] b = new int[m];
		for (int i = 0; i < m; i++) {
			b[i] = Integer.parseInt(sa[i]);
		}
		br.close();

		long[] dpa = dp(a);
		long[] dpb = dp(b);
		long ans = 0;
		for (int i = 0; i < mx; i++) {
			int j = k ^ i;
			ans += dpa[i] * dpb[j];
			ans %= mod;
		}
		System.out.println(ans);
	}

	static long[] dp(int[] a) {
		long[] dp = new long[mx];
		Map<Integer, Long> now = new HashMap<>();
		for (int i = 0; i < a.length; i++) {
			Map<Integer, Long> next = new HashMap<>();
			for (int j : now.keySet()) {
				int key = j ^ a[i];
				next.put(key, next.getOrDefault(key, 0L) + now.get(j));
			}
			next.put(a[i], next.getOrDefault(a[i], 0L) + 1);
			for (Integer j : next.keySet()) {
				next.put(j, next.get(j) % mod);
				dp[j] += next.get(j);
				dp[j] %= mod;
			}
			now = next;
		}
		return dp;
	}
}
0