結果

問題 No.1142 XOR と XOR
ユーザー marroncastle
提出日時 2020-07-31 23:55:50
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 154 ms / 2,000 ms
コード長 782 bytes
コンパイル時間 1,976 ms
コンパイル使用メモリ 81,536 KB
実行使用メモリ 114,560 KB
最終ジャッジ日時 2024-11-08 03:37:28
合計ジャッジ時間 5,058 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

def solve():
  mod = 10**9+7
  N, M, K = map(int, input().split())
  A = list(map(int, input().split()))
  B = list(map(int, input().split()))
  cum_a,cum_b = [0]*(1<<10),[0]*(1<<10)
  cum_a[0],cum_b[0] = 1,1
  now_a,now_b = 0,0
  for i in range(N):
    now_a ^= A[i]
    cum_a[now_a] += 1
  for j in range(M):
    now_b ^= B[j]
    cum_b[now_b] += 1
  a2,b2 = [0]*(1<<10),[0]*(1<<10)
  for i in range(1<<10):
    for j in range(i,1<<10):
      if i==j:
        a2[i^j] += cum_a[i]*(cum_a[i]-1)//2
        b2[i^j] += cum_b[i]*(cum_b[i]-1)//2
      else:
        a2[i^j] += cum_a[i]*cum_a[j]
        b2[i^j] += cum_b[i]*cum_b[j]
      a2[i^j] %= mod
      b2[i^j] %= mod
  ans = 0
  for i in range(1<<10):
    j = K^i
    ans += a2[i]*b2[j]
    ans %= mod
  return ans
print(solve())
0