結果

問題 No.1245 ANDORゲーム(calc)
ユーザー roarisroaris
提出日時 2022-11-29 19:04:20
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 329 ms / 2,000 ms
コード長 663 bytes
コンパイル時間 390 ms
コンパイル使用メモリ 82,408 KB
実行使用メモリ 94,592 KB
最終ジャッジ日時 2024-04-16 12:22:55
合計ジャッジ時間 9,037 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
52,352 KB
testcase_01 AC 37 ms
52,548 KB
testcase_02 AC 37 ms
52,480 KB
testcase_03 AC 38 ms
52,224 KB
testcase_04 AC 36 ms
51,968 KB
testcase_05 AC 38 ms
52,096 KB
testcase_06 AC 37 ms
52,224 KB
testcase_07 AC 71 ms
72,704 KB
testcase_08 AC 59 ms
66,816 KB
testcase_09 AC 71 ms
72,960 KB
testcase_10 AC 65 ms
70,528 KB
testcase_11 AC 326 ms
91,696 KB
testcase_12 AC 329 ms
92,216 KB
testcase_13 AC 305 ms
91,848 KB
testcase_14 AC 322 ms
92,140 KB
testcase_15 AC 310 ms
92,128 KB
testcase_16 AC 305 ms
91,852 KB
testcase_17 AC 286 ms
92,144 KB
testcase_18 AC 283 ms
91,664 KB
testcase_19 AC 275 ms
92,140 KB
testcase_20 AC 295 ms
92,296 KB
testcase_21 AC 288 ms
91,880 KB
testcase_22 AC 274 ms
92,188 KB
testcase_23 AC 293 ms
92,040 KB
testcase_24 AC 301 ms
91,780 KB
testcase_25 AC 218 ms
94,592 KB
testcase_26 AC 221 ms
93,780 KB
testcase_27 AC 254 ms
92,240 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

N, Q = map(int, input().split())
A = list(map(int, input().split()))
S = input()[:-1]
add = [[0]*2 for _ in range(35)]

for i in range(35):
    for j in range(2):
        now = j
        
        for k in range(N):
            if S[k]=='0':
                nex = now&((A[k]>>i)&1)
            else:
                nex = now|((A[k]>>i)&1)
            
            add[i][j] += (1<<i)*abs(now-nex)
            now = nex

t = list(map(int, input().split()))

for ti in t:
    ans = 0
    
    for i in range(35):
        if (ti>>i)&1:
            ans += add[i][1]
        else:
            ans += add[i][0]
    
    print(ans)
0