結果

問題 No.1142 XOR と XOR
ユーザー ks2mks2m
提出日時 2020-07-31 22:45:02
言語 Java21
(openjdk 21)
結果
TLE  
実行時間 -
コード長 1,298 bytes
コンパイル時間 2,013 ms
コンパイル使用メモリ 74,040 KB
実行使用メモリ 92,276 KB
最終ジャッジ日時 2023-09-21 01:20:16
合計ジャッジ時間 6,041 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
49,628 KB
testcase_01 AC 44 ms
49,348 KB
testcase_02 AC 45 ms
49,324 KB
testcase_03 TLE -
testcase_04 -- -
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;

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];
		long[] now = new long[mx];
		for (int i = 0; i < a.length; i++) {
			long[] next = new long[mx];
			for (int j = 0; j < mx; j++) {
				next[j ^ a[i]] += now[j];
			}
			next[a[i]]++;
			for (int j = 0; j < mx; j++) {
				next[j] %= mod;
			}
			for (int j = 0; j < mx; j++) {
				dp[j] += next[j];
				dp[j] %= mod;
			}
			now = next;
		}
		return dp;
	}
}
0