結果

問題 No.1245 ANDORゲーム(calc)
ユーザー Eki1009Eki1009
提出日時 2020-10-02 22:21:03
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 265 ms / 2,000 ms
コード長 621 bytes
コンパイル時間 269 ms
コンパイル使用メモリ 87,036 KB
実行使用メモリ 95,648 KB
最終ジャッジ日時 2023-09-24 21:18:30
合計ジャッジ時間 7,752 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,276 KB
testcase_01 AC 72 ms
71,356 KB
testcase_02 AC 73 ms
71,180 KB
testcase_03 AC 71 ms
71,316 KB
testcase_04 AC 77 ms
71,456 KB
testcase_05 AC 71 ms
71,332 KB
testcase_06 AC 71 ms
71,244 KB
testcase_07 AC 102 ms
77,104 KB
testcase_08 AC 88 ms
76,936 KB
testcase_09 AC 94 ms
76,812 KB
testcase_10 AC 93 ms
77,096 KB
testcase_11 AC 260 ms
93,352 KB
testcase_12 AC 260 ms
93,932 KB
testcase_13 AC 261 ms
93,908 KB
testcase_14 AC 257 ms
93,864 KB
testcase_15 AC 260 ms
93,756 KB
testcase_16 AC 261 ms
93,716 KB
testcase_17 AC 246 ms
93,836 KB
testcase_18 AC 246 ms
93,624 KB
testcase_19 AC 233 ms
93,748 KB
testcase_20 AC 252 ms
94,024 KB
testcase_21 AC 244 ms
93,856 KB
testcase_22 AC 238 ms
94,136 KB
testcase_23 AC 259 ms
93,760 KB
testcase_24 AC 265 ms
93,788 KB
testcase_25 AC 188 ms
95,648 KB
testcase_26 AC 195 ms
95,456 KB
testcase_27 AC 217 ms
93,916 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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