結果

問題 No.1245 ANDORゲーム(calc)
ユーザー 👑 rin204rin204
提出日時 2022-07-06 21:36:16
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 384 ms / 2,000 ms
コード長 584 bytes
コンパイル時間 748 ms
コンパイル使用メモリ 86,708 KB
実行使用メモリ 95,232 KB
最終ジャッジ日時 2023-08-24 21:13:11
合計ジャッジ時間 11,889 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
70,920 KB
testcase_01 AC 71 ms
71,096 KB
testcase_02 AC 70 ms
70,792 KB
testcase_03 AC 71 ms
71,056 KB
testcase_04 AC 70 ms
70,956 KB
testcase_05 AC 69 ms
71,240 KB
testcase_06 AC 70 ms
71,280 KB
testcase_07 AC 106 ms
77,296 KB
testcase_08 AC 92 ms
76,756 KB
testcase_09 AC 106 ms
77,236 KB
testcase_10 AC 99 ms
77,220 KB
testcase_11 AC 378 ms
93,520 KB
testcase_12 AC 358 ms
93,972 KB
testcase_13 AC 363 ms
93,464 KB
testcase_14 AC 384 ms
93,828 KB
testcase_15 AC 357 ms
94,272 KB
testcase_16 AC 356 ms
93,516 KB
testcase_17 AC 348 ms
94,328 KB
testcase_18 AC 337 ms
93,560 KB
testcase_19 AC 347 ms
93,688 KB
testcase_20 AC 357 ms
91,396 KB
testcase_21 AC 347 ms
93,892 KB
testcase_22 AC 350 ms
94,600 KB
testcase_23 AC 358 ms
93,692 KB
testcase_24 AC 350 ms
93,340 KB
testcase_25 AC 215 ms
95,232 KB
testcase_26 AC 260 ms
95,072 KB
testcase_27 AC 315 ms
93,756 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, Q = map(int, input().split())
A = list(map(int, input().split()))
S = input()
cnt = [[0] * 2 for _ in range(30)]
for i in range(30):
    for j in range(2):
        if j == 0:
            x = 0
        else:
            x = 1 << i
        for a, s in zip(A, S):
            b = (a >> i & 1) << i
            if s == "0":
                nx = x & b
            else:
                nx = x | b
            cnt[i][j] += abs(x - nx)
            x = nx

T = list(map(int, input().split()))
for t in T:
    ans = 0
    for i in range(30):
        ans += cnt[i][t >> i & 1]
    print(ans)
0