結果

問題 No.3205 Range Pairwise Xor Query
コンテスト
ユーザー ntuda
提出日時 2025-11-15 15:54:59
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 452 bytes
コンパイル時間 444 ms
コンパイル使用メモリ 82,324 KB
実行使用メモリ 67,708 KB
最終ジャッジ日時 2025-11-15 15:55:03
合計ジャッジ時間 4,536 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample RE * 1
other RE * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

from atcoder.segtree import SegTree
N,Q = map(int,input().split())
A = map(int,input().split())
X = [[0] * N for _ in range(26)]
for i,a in enumerate(A):
    for j in range(26):
        X[j][i] = a & 1
        a >>= 1

X = [SegTree(lambda x,y:x+y, 0, X[i]) for i in range(26)]
for _ in range(Q):
    L,R = map(int,input().split())
    ans = 0
    for i in range(26):
        x = X[i].prod(L-1,R)
        ans += ((R-L+1-x) * x) * (1<<i)
    print(ans)

0