結果

問題 No.1142 XOR と XOR
ユーザー tyawanmusityawanmusi
提出日時 2020-06-27 16:30:24
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 626 ms / 2,000 ms
コード長 972 bytes
コンパイル時間 101 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 37,624 KB
最終ジャッジ日時 2024-04-25 16:11:53
合計ジャッジ時間 14,459 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 285 ms
10,752 KB
testcase_01 AC 291 ms
10,752 KB
testcase_02 AC 307 ms
10,752 KB
testcase_03 AC 539 ms
37,624 KB
testcase_04 AC 548 ms
28,192 KB
testcase_05 AC 517 ms
25,552 KB
testcase_06 AC 559 ms
31,576 KB
testcase_07 AC 485 ms
16,608 KB
testcase_08 AC 591 ms
34,980 KB
testcase_09 AC 605 ms
34,936 KB
testcase_10 AC 626 ms
34,900 KB
testcase_11 AC 287 ms
10,752 KB
testcase_12 AC 280 ms
10,752 KB
testcase_13 AC 282 ms
10,752 KB
testcase_14 AC 457 ms
27,012 KB
testcase_15 AC 462 ms
25,708 KB
testcase_16 AC 332 ms
11,904 KB
testcase_17 AC 439 ms
15,612 KB
testcase_18 AC 327 ms
12,160 KB
testcase_19 AC 578 ms
31,004 KB
testcase_20 AC 498 ms
25,964 KB
testcase_21 AC 430 ms
21,628 KB
testcase_22 AC 391 ms
14,972 KB
testcase_23 AC 539 ms
29,820 KB
testcase_24 AC 585 ms
31,328 KB
testcase_25 AC 404 ms
21,476 KB
testcase_26 AC 501 ms
33,996 KB
testcase_27 AC 441 ms
23,004 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# Tester解

# 入力
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

# 累積xor
for i in range(1, n):
  a[i] ^= a[i - 1]
for j in range(1, m):
  b[j] ^= b[j - 1]

# なんかうまくカウントするアレ
a1 = [0] * 1024
b1 = [0] * 1024
for x in a:
  a1[x] += 1
for y in b:
  b1[y] += 1

# 全探索パート
# i == j のときは重複して数えないように場合分け
a2 = [0] * 1024
b2 = [0] * 1024
for i in range(1024):
  for j in range(i, 1024):
    if i == j:
      a2[i ^ j] += a1[i] * (a1[j] - 1) // 2
      b2[i ^ j] += b1[i] * (b1[j] - 1) // 2
    else:
      a2[i ^ j] += a1[i] * a1[j]
      b2[i ^ j] += b1[i] * b1[j]

# 最後の計算
# a1_i + a2_i が i を作る (n, u) の総数
# b1_j + b2_j が j を作る (l1, l2) の総数
# i を全探索して求める
ans = 0
for i in range(1024):
  j = k ^ i
  ans += (a1[i] + a2[i]) * (b1[j] + b2[j])
  ans %= 10**9+7

# 出力
print(ans)
0