結果

問題 No.1245 ANDORゲーム(calc)
ユーザー 👑 KazunKazun
提出日時 2021-06-16 04:31:55
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 406 ms / 2,000 ms
コード長 893 bytes
コンパイル時間 1,208 ms
コンパイル使用メモリ 86,892 KB
実行使用メモリ 114,780 KB
最終ジャッジ日時 2023-08-28 11:54:49
合計ジャッジ時間 12,570 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
70,716 KB
testcase_01 AC 76 ms
71,060 KB
testcase_02 AC 75 ms
71,068 KB
testcase_03 AC 75 ms
71,008 KB
testcase_04 AC 75 ms
71,128 KB
testcase_05 AC 76 ms
71,076 KB
testcase_06 AC 76 ms
70,888 KB
testcase_07 AC 132 ms
77,624 KB
testcase_08 AC 105 ms
77,660 KB
testcase_09 AC 115 ms
77,744 KB
testcase_10 AC 114 ms
77,520 KB
testcase_11 AC 406 ms
113,900 KB
testcase_12 AC 391 ms
114,780 KB
testcase_13 AC 381 ms
114,128 KB
testcase_14 AC 382 ms
114,576 KB
testcase_15 AC 384 ms
114,572 KB
testcase_16 AC 391 ms
114,064 KB
testcase_17 AC 365 ms
113,640 KB
testcase_18 AC 365 ms
113,368 KB
testcase_19 AC 366 ms
113,368 KB
testcase_20 AC 365 ms
113,464 KB
testcase_21 AC 354 ms
113,400 KB
testcase_22 AC 362 ms
113,608 KB
testcase_23 AC 372 ms
114,396 KB
testcase_24 AC 355 ms
113,180 KB
testcase_25 AC 276 ms
108,536 KB
testcase_26 AC 287 ms
108,404 KB
testcase_27 AC 343 ms
114,344 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from operator import __and__,__or__
from sys import stdout
write=stdout.write

N,Q=map(int,input().split())
A=["*"]+list(map(int,input().split()))
S=["*"]+list(map(int,input()))
T=["*"]+list(map(int,input().split()))

a_bit=30

V=[[0,(1<<a_bit)-1] for _ in range(N+1)]
U=[[0,0] for _ in range(a_bit)]

for i in range(1,N+1):
    a=A[i]; s=S[i]
    op=__or__ if s else __and__

    V[i][0]=op(V[i-1][0],a)
    V[i][1]=op(V[i-1][1],a)

    b=1
    for k in range(a_bit):
        if s==0:
            for m in [0,1]:
                if V[i-1][m]&b==b and V[i][m]&b==0:
                    U[k][m]+=b
        else:
            for m in [0,1]:
                if V[i-1][m]&b==0 and V[i][m]&b==b:
                    U[k][m]+=b
        b<<=1

X=[]; X_append=X.append
for t in T[1:]:
    x=0
    for k in range(a_bit):
        x+=U[k][t&1]
        t>>=1
    X_append(x)

write("\n".join(map(str,X)))
0