結果

問題 No.1245 ANDORゲーム(calc)
コンテスト
ユーザー 👑 rin204
提出日時 2022-07-06 21:36:16
言語 PyPy3
(8.0.0 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 203 ms / 2,000 ms
+ 678µs
コード長 584 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 61 ms
コンパイル使用メモリ 82,904 KB
実行使用メモリ 111,200 KB
最終ジャッジ日時 2026-10-06 10:06:16
合計ジャッジ時間 7,676 ms
ジャッジサーバーID
(参考情報)
judge2_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 = input()
cnt = [[0] * 2 for _ in range(30)]
for i in range(30):
    for j in range(2):
        if j == 0:
            x = 0
        else:
            x = 1 << i
        for a, s in zip(A, S):
            b = (a >> i & 1) << i
            if s == "0":
                nx = x & b
            else:
                nx = x | b
            cnt[i][j] += abs(x - nx)
            x = nx

T = list(map(int, input().split()))
for t in T:
    ans = 0
    for i in range(30):
        ans += cnt[i][t >> i & 1]
    print(ans)
0