結果

問題 No.1245 ANDORゲーム(calc)
コンテスト
ユーザー rlangevin
提出日時 2023-03-22 08:58:57
言語 PyPy3
(7.3.23 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 225 ms / 2,000 ms
+ 798µs
コード長 576 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 272 ms
コンパイル使用メモリ 95,672 KB
実行使用メモリ 119,040 KB
最終ジャッジ日時 2026-08-30 06:53:49
合計ジャッジ時間 8,521 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

N, Q = map(int, input().split())
A = list(map(int, input().split()))
S = list(input())
S = list(map(int, S))
T = list(map(int, input().split()))

M = 35
L = [[0] * 2 for i in range(M)]
for i in range(M):
    for j in range(2):
        now = j
        for n in range(N):
            a = (A[n] >> i) & 1
            if S[n]:
                nex = now | a
            else:
                nex = now & a
            L[i][j] += nex ^ now
            now = nex

for t in T:
    ans = 0
    for i in range(M):
        ans += (1 << i) * L[i][(t >> i) & 1]
            
    print(ans)
0