結果

問題 No.3205 Range Pairwise Xor Query
ユーザー timi
提出日時 2025-07-18 21:39:29
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,530 ms / 2,000 ms
コード長 372 bytes
コンパイル時間 222 ms
コンパイル使用メモリ 82,236 KB
実行使用メモリ 260,316 KB
最終ジャッジ日時 2025-07-18 21:40:20
合計ジャッジ時間 18,401 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

N,Q=map(int, input().split())
A=list(map(int, input().split()))
C=[[0] for i in range(30)]
for a in A:
  b=a
  for i in range(30):
    C[i].append(C[i][-1])
    if b%2==1:
      C[i][-1]+=1
    b//=2

for _ in range(Q):
  l,r=map(int, input().split())
  l-=1
  ans=0
  c=1
  for i in range(30):
    y=C[i][r]-C[i][l]
    x=r-l-y 
    ans+=c*x*y
    c*=2 
  print(ans)
    
0