結果

問題 No.1245 ANDORゲーム(calc)
コンテスト
ユーザー ああ
提出日時 2026-05-27 20:06:53
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 145 ms / 2,000 ms
コード長 490 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 421 ms
コンパイル使用メモリ 85,376 KB
実行使用メモリ 112,384 KB
最終ジャッジ日時 2026-05-27 20:07:00
合計ジャッジ時間 6,990 ms
ジャッジサーバーID
(参考情報)
judge1_1 / judge2_0
純コード判定待ち
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

n,q=map(int,input().split())
t=list(map(int,input().split()))
s=list(map(int,list(input())))
x=[[0,0] for i in range(30)]
for j in range(30):
    v=1<<j
    a,b=0,1
    c,d=0,0
    for i in range(n):
        f=t[i]&1;t[i]>>=1
        if s[i]:
            q,w=a|f,b|f
        else:
            q,w=a&f,b&f
        c+=abs(q-a)*v;d+=abs(w-b)*v
        a,b=q,w
    x[j]=[c,d]
for i in list(map(int,input().split())):
    ans=0
    for j in range(30):
        ans+=x[j][i&1];i>>=1
    print(ans)
0