結果

問題 No.1245 ANDORゲーム(calc)
ユーザー naniwazunaniwazu
提出日時 2020-10-02 22:20:23
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 349 ms / 2,000 ms
コード長 1,272 bytes
コンパイル時間 289 ms
コンパイル使用メモリ 87,104 KB
実行使用メモリ 96,916 KB
最終ジャッジ日時 2023-09-24 21:17:14
合計ジャッジ時間 8,841 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,356 KB
testcase_01 AC 72 ms
71,236 KB
testcase_02 AC 71 ms
71,392 KB
testcase_03 AC 70 ms
71,416 KB
testcase_04 AC 74 ms
71,368 KB
testcase_05 AC 70 ms
71,196 KB
testcase_06 AC 71 ms
70,996 KB
testcase_07 AC 122 ms
77,852 KB
testcase_08 AC 107 ms
77,524 KB
testcase_09 AC 119 ms
77,920 KB
testcase_10 AC 116 ms
77,676 KB
testcase_11 AC 347 ms
96,600 KB
testcase_12 AC 349 ms
96,916 KB
testcase_13 AC 343 ms
96,808 KB
testcase_14 AC 346 ms
96,884 KB
testcase_15 AC 341 ms
96,748 KB
testcase_16 AC 342 ms
96,508 KB
testcase_17 AC 311 ms
95,980 KB
testcase_18 AC 297 ms
96,812 KB
testcase_19 AC 295 ms
96,200 KB
testcase_20 AC 316 ms
96,340 KB
testcase_21 AC 316 ms
96,068 KB
testcase_22 AC 296 ms
96,144 KB
testcase_23 AC 328 ms
95,960 KB
testcase_24 AC 321 ms
96,624 KB
testcase_25 AC 209 ms
95,456 KB
testcase_26 AC 214 ms
95,460 KB
testcase_27 AC 247 ms
96,200 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,Q = map(int,input().split())
A = list(map(int,input().split()))
S = list(map(int,input()))
t = list(map(int,input().split()))
score = [[0,0] for _ in range(32)]
for i in range(32):
    bit = 0
    s = 0
    for j in range(N):
        if S[j]:
            if bit or (A[j] >> i & 1):
                s += abs(bit-1)*(1 << i)
                bit = 1
            else:
                s += abs(bit)*(1 << i)
                bit = 0
        else:
            if bit and (A[j] >> i & 1):
                s += abs(bit-1)*(1 << i)
                bit = 1
            else:
                s += abs(bit)*(1 << i)
                bit = 0
    score[i][0] = s
    bit = 1
    s = 0
    for j in range(N):
        if S[j]:
            if bit or (A[j] >> i & 1):
                s += abs(bit-1)*(1 << i)
                bit = 1
            else:
                s += abs(bit)*(1 << i)
                bit = 0
        else:
            if bit and (A[j] >> i & 1):
                s += abs(bit-1)*(1 << i)
                bit = 1
            else:
                s += abs(bit)*(1 << i)
                bit = 0
    score[i][1] = s
for ti in t:
    s = 0
    for i in range(32):
        if ti >> i & 1:
            s += score[i][1]
        else:
            s += score[i][0]
    print(s)
0