結果

問題 No.1245 ANDORゲーム(calc)
ユーザー AEnAEn
提出日時 2022-12-06 21:39:45
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 400 ms / 2,000 ms
コード長 850 bytes
コンパイル時間 176 ms
コンパイル使用メモリ 82,560 KB
実行使用メモリ 95,884 KB
最終ジャッジ日時 2024-04-21 10:39:05
合計ジャッジ時間 10,530 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 63 ms
63,232 KB
testcase_01 AC 72 ms
62,848 KB
testcase_02 AC 62 ms
63,232 KB
testcase_03 AC 61 ms
62,976 KB
testcase_04 AC 62 ms
63,104 KB
testcase_05 AC 62 ms
62,976 KB
testcase_06 AC 61 ms
63,232 KB
testcase_07 AC 121 ms
77,952 KB
testcase_08 AC 102 ms
77,440 KB
testcase_09 AC 106 ms
77,952 KB
testcase_10 AC 107 ms
78,208 KB
testcase_11 AC 400 ms
93,836 KB
testcase_12 AC 390 ms
94,136 KB
testcase_13 AC 394 ms
94,028 KB
testcase_14 AC 391 ms
94,060 KB
testcase_15 AC 399 ms
94,136 KB
testcase_16 AC 400 ms
93,916 KB
testcase_17 AC 362 ms
94,192 KB
testcase_18 AC 360 ms
93,748 KB
testcase_19 AC 366 ms
93,528 KB
testcase_20 AC 373 ms
94,320 KB
testcase_21 AC 370 ms
94,052 KB
testcase_22 AC 369 ms
94,260 KB
testcase_23 AC 375 ms
93,708 KB
testcase_24 AC 371 ms
93,904 KB
testcase_25 AC 314 ms
95,860 KB
testcase_26 AC 325 ms
95,884 KB
testcase_27 AC 357 ms
94,200 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from re import I


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

bit = [1<<i for i in range(30)]
cal = [[0]*2 for _ in range(30)]
num = [[0,1] for _ in range(30)]
for i in range(len(S)):
    for j in range(30):
        for k in range(2):
            b1 = num[j][k]
            b2 = 1 if A[i]&bit[j] else 0
            if S[i]=='0':
                nex = b1&b2
                if nex!=b1:
                    cal[j][k] += bit[j]
                num[j][k] = nex
            else:
                nex = b1|b2
                if nex!=b1:
                    cal[j][k] += bit[j]
                num[j][k] = nex
for i in range(Q):
    score = 0
    for j in range(30):
        if t[i]&bit[j]:
            score += cal[j][1]
        else:
            score += cal[j][0]
    print(score)
0