結果

問題 No.1245 ANDORゲーム(calc)
ユーザー mkawa2mkawa2
提出日時 2022-03-05 09:21:20
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 305 ms / 2,000 ms
コード長 1,330 bytes
コンパイル時間 358 ms
コンパイル使用メモリ 87,116 KB
実行使用メモリ 95,468 KB
最終ジャッジ日時 2023-09-26 15:03:16
合計ジャッジ時間 9,468 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,124 KB
testcase_01 AC 73 ms
71,016 KB
testcase_02 AC 77 ms
71,240 KB
testcase_03 AC 76 ms
71,244 KB
testcase_04 AC 75 ms
71,024 KB
testcase_05 AC 76 ms
70,956 KB
testcase_06 AC 73 ms
71,204 KB
testcase_07 AC 109 ms
77,356 KB
testcase_08 AC 97 ms
76,764 KB
testcase_09 AC 109 ms
77,352 KB
testcase_10 AC 104 ms
77,256 KB
testcase_11 AC 305 ms
92,392 KB
testcase_12 AC 289 ms
92,852 KB
testcase_13 AC 283 ms
92,520 KB
testcase_14 AC 294 ms
92,992 KB
testcase_15 AC 284 ms
92,952 KB
testcase_16 AC 282 ms
92,712 KB
testcase_17 AC 295 ms
90,784 KB
testcase_18 AC 286 ms
92,268 KB
testcase_19 AC 274 ms
92,552 KB
testcase_20 AC 281 ms
91,104 KB
testcase_21 AC 276 ms
90,392 KB
testcase_22 AC 274 ms
93,076 KB
testcase_23 AC 290 ms
92,572 KB
testcase_24 AC 284 ms
92,652 KB
testcase_25 AC 189 ms
95,468 KB
testcase_26 AC 218 ms
92,880 KB
testcase_27 AC 261 ms
93,052 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

# sys.setrecursionlimit(200005)
int1 = lambda x: int(x)-1
pDB = lambda *x: print(*x, end="\n", file=sys.stderr)
p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr)
def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def SI(): return sys.stdin.readline().rstrip()
dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
inf = (1 << 63)-1
# inf = (1 << 31)-1
md = 10**9+7
# md = 998244353

n, q = LI()
aa = LI()
s = SI()

mask = 1
ss = []
for k in range(31):
    s0 = s1 = 0
    x0, x1 = 0, mask
    for a, c in zip(aa, s):
        a &= mask
        if c == "0":
            s0 += abs(x0-(x0 & a))
            s1 += abs(x1-(x1 & a))
            x0 &= a
            x1 &= a
        else:
            s0 += abs(x0-(x0 | a))
            s1 += abs(x1-(x1 | a))
            x0 |= a
            x1 |= a
    mask <<= 1
    ss.append([s0, s1])

for t in LI():
    ans = 0
    for k in range(31):
        if t >> k & 1:
            ans += ss[k][1]
        else:
            ans += ss[k][0]
    print(ans)
0