結果

問題 No.1245 ANDORゲーム(calc)
コンテスト
ユーザー Eki1009
提出日時 2020-10-02 22:20:39
言語 Python3
(3.14.3 + numpy 2.4.4 + scipy 1.17.1)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
TLE  
実行時間 -
コード長 621 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 494 ms
コンパイル使用メモリ 20,948 KB
実行使用メモリ 28,968 KB
最終ジャッジ日時 2026-04-01 12:43:27
合計ジャッジ時間 10,932 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 8 TLE * 17
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

n, q = map(int, input().split())
A = list(map(int, input().split()))
S = input()
U = 31
dp = [[0]*U for _ in range(2)]
for i in range(2):
    for j in range(U):
        now, temp = i, 0
        for k, a in enumerate(A):
            if S[k] == "0":
                nxt = now & (a>>j & 1)
                temp += now - nxt
                now = nxt
            else:
                nxt = now | (a>>j & 1)
                temp += nxt - now
                now = nxt
        dp[i][j] = temp
T = list(map(int, input().split()))
for t in T:
    ans = 0
    for j in range(U):
        ans += dp[t>>j & 1][j] << j
    print(ans)
0