結果
| 問題 |
No.1142 XOR と XOR
|
| ユーザー |
tenten
|
| 提出日時 | 2021-12-07 09:43:04 |
| 言語 | Java (openjdk 23) |
| 結果 |
TLE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 2,245 bytes |
| コンパイル時間 | 4,975 ms |
| コンパイル使用メモリ | 77,520 KB |
| 実行使用メモリ | 50,252 KB |
| 最終ジャッジ日時 | 2024-11-08 04:00:07 |
| 合計ジャッジ時間 | 41,256 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 19 TLE * 6 |
ソースコード
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();
}
}
tenten