結果

問題 No.1245 ANDORゲーム(calc)
ユーザー ayaoniayaoni
提出日時 2020-12-11 09:25:58
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 255 ms / 2,000 ms
コード長 1,250 bytes
コンパイル時間 156 ms
コンパイル使用メモリ 81,856 KB
実行使用メモリ 101,136 KB
最終ジャッジ日時 2023-10-20 01:22:17
合計ジャッジ時間 9,291 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
53,456 KB
testcase_01 AC 35 ms
53,456 KB
testcase_02 AC 37 ms
53,456 KB
testcase_03 AC 36 ms
53,456 KB
testcase_04 AC 36 ms
53,456 KB
testcase_05 AC 37 ms
53,456 KB
testcase_06 AC 36 ms
53,456 KB
testcase_07 AC 70 ms
75,824 KB
testcase_08 AC 57 ms
68,624 KB
testcase_09 AC 72 ms
76,032 KB
testcase_10 AC 65 ms
73,112 KB
testcase_11 AC 255 ms
96,108 KB
testcase_12 AC 250 ms
96,848 KB
testcase_13 AC 243 ms
97,080 KB
testcase_14 AC 253 ms
97,388 KB
testcase_15 AC 247 ms
97,344 KB
testcase_16 AC 248 ms
97,052 KB
testcase_17 AC 244 ms
97,744 KB
testcase_18 AC 230 ms
98,348 KB
testcase_19 AC 232 ms
97,548 KB
testcase_20 AC 244 ms
97,516 KB
testcase_21 AC 236 ms
98,640 KB
testcase_22 AC 236 ms
98,968 KB
testcase_23 AC 245 ms
97,368 KB
testcase_24 AC 238 ms
97,508 KB
testcase_25 AC 161 ms
101,136 KB
testcase_26 AC 183 ms
101,136 KB
testcase_27 AC 217 ms
100,368 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def LS2(): return list(sys.stdin.readline().rstrip())


N,Q = MI()
A = LI()
S = S()
T = LI()

zero_start = []
one_start = []
for i in range(30):
    z,o = 0,1
    score_zero,score_one = 0,0
    for j in range(N):
        a = (A[j]>>i) & 1
        s = S[j]
        if S[j] == '0':
            if z != z & a:
                score_zero += 1
            if o != o & a:
                score_one += 1
            z = z & a
            o = o & a
        else:
            if z != z | a:
                score_zero += 1
            if o != o | a:
                score_one += 1
            z = z | a
            o = o | a
    zero_start.append(score_zero<<i)
    one_start.append(score_one<<i)

for t in T:
    ans = 0
    for i in range(30):
        if (t>>i) & 1:
            ans += one_start[i]
        else:
            ans += zero_start[i]
    print(ans)
0