結果
問題 |
No.1142 XOR と XOR
|
ユーザー |
![]() |
提出日時 | 2022-08-31 11:01:05 |
言語 | Java (openjdk 23) |
結果 |
TLE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 2,332 bytes |
コンパイル時間 | 2,409 ms |
コンパイル使用メモリ | 77,636 KB |
実行使用メモリ | 59,764 KB |
最終ジャッジ日時 | 2024-11-08 04:01:21 |
合計ジャッジ時間 | 38,289 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 20 TLE * 5 |
ソースコード
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(); long[] current = new long[1024]; long[] next = new long[1024]; long[] sumA = new long[1024]; for (int i = 0; i < n; i++) { int x = sc.nextInt(); next[x]++; sumA[x]++; for (int j = 0; j < 1024; j++) { next[x ^ j] += current[j]; next[x ^ j] %= MOD; sumA[x ^ j] += current[j]; sumA[x ^ j] %= MOD; } long[] tmp = current; current = next; next = tmp; Arrays.fill(next, 0); } long[] sumB = new long[1024]; Arrays.fill(current, 0); for (int i = 0; i < m; i++) { int x = sc.nextInt(); next[x]++; sumB[x]++; for (int j = 0; j < 1024; j++) { next[x ^ j] += current[j]; next[x ^ j] %= MOD; sumB[x ^ j] += current[j]; sumB[x ^ j] %= MOD; } long[] tmp = current; current = next; next = tmp; Arrays.fill(next, 0); } long ans = 0; for (int i = 0; i < 1024; i++) { ans += sumA[i] * sumB[i ^ k] % MOD; ans %= MOD; } System.out.println(ans); } } class Scanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); StringBuilder sb = new StringBuilder(); 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 { while (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } return st.nextToken(); } }