結果

問題 No.1245 ANDORゲーム(calc)
ユーザー rlangevinrlangevin
提出日時 2023-03-22 08:58:57
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 280 ms / 2,000 ms
コード長 576 bytes
コンパイル時間 262 ms
コンパイル使用メモリ 81,816 KB
実行使用メモリ 98,276 KB
最終ジャッジ日時 2023-10-18 18:50:24
合計ジャッジ時間 10,356 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,428 KB
testcase_01 AC 37 ms
53,428 KB
testcase_02 AC 37 ms
53,428 KB
testcase_03 AC 38 ms
53,428 KB
testcase_04 AC 38 ms
53,428 KB
testcase_05 AC 37 ms
53,428 KB
testcase_06 AC 37 ms
53,428 KB
testcase_07 AC 64 ms
68,652 KB
testcase_08 AC 55 ms
64,508 KB
testcase_09 AC 64 ms
68,668 KB
testcase_10 AC 62 ms
68,628 KB
testcase_11 AC 280 ms
97,640 KB
testcase_12 AC 280 ms
97,640 KB
testcase_13 AC 278 ms
97,628 KB
testcase_14 AC 279 ms
97,616 KB
testcase_15 AC 277 ms
97,640 KB
testcase_16 AC 277 ms
97,640 KB
testcase_17 AC 264 ms
97,388 KB
testcase_18 AC 252 ms
97,184 KB
testcase_19 AC 251 ms
97,352 KB
testcase_20 AC 263 ms
97,508 KB
testcase_21 AC 258 ms
97,316 KB
testcase_22 AC 254 ms
97,304 KB
testcase_23 AC 278 ms
97,580 KB
testcase_24 AC 274 ms
97,556 KB
testcase_25 AC 189 ms
98,276 KB
testcase_26 AC 198 ms
98,276 KB
testcase_27 AC 229 ms
96,904 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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