結果
| 問題 |
No.1142 XOR と XOR
|
| コンテスト | |
| ユーザー |
lam6er
|
| 提出日時 | 2025-04-15 23:44:52 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 1,530 ms / 2,000 ms |
| コード長 | 915 bytes |
| コンパイル時間 | 238 ms |
| コンパイル使用メモリ | 82,216 KB |
| 実行使用メモリ | 154,996 KB |
| 最終ジャッジ日時 | 2025-04-15 23:47:38 |
| 合計ジャッジ時間 | 24,221 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 25 |
ソースコード
MOD = 10**9 + 7
def compute_cnt(arr):
cnt = [0] * 1024
freq = [0] * 1024
pre = 0
freq[pre] += 1
for num in arr:
pre ^= num
for x in range(1024):
target = pre ^ x
cnt[x] += freq[target]
if cnt[x] >= MOD:
cnt[x] -= MOD
freq[pre] += 1
for x in range(1024):
cnt[x] %= MOD
return cnt
def main():
import sys
input = sys.stdin.read().split()
ptr = 0
N = int(input[ptr])
ptr += 1
M = int(input[ptr])
ptr += 1
K = int(input[ptr])
ptr += 1
a = list(map(int, input[ptr:ptr+N]))
ptr += N
b = list(map(int, input[ptr:ptr+M]))
ptr += M
cnt_a = compute_cnt(a)
cnt_b = compute_cnt(b)
ans = 0
for x in range(1024):
y = x ^ K
ans = (ans + cnt_a[x] * cnt_b[y]) % MOD
print(ans % MOD)
if __name__ == "__main__":
main()
lam6er