結果

問題 No.1245 ANDORゲーム(calc)
ユーザー tanon710tanon710
提出日時 2020-10-02 22:30:04
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 314 ms / 2,000 ms
コード長 1,078 bytes
コンパイル時間 900 ms
コンパイル使用メモリ 86,956 KB
実行使用メモリ 99,276 KB
最終ジャッジ日時 2023-09-24 21:39:02
合計ジャッジ時間 8,612 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,120 KB
testcase_01 AC 74 ms
71,204 KB
testcase_02 AC 74 ms
71,524 KB
testcase_03 AC 75 ms
71,232 KB
testcase_04 AC 73 ms
71,440 KB
testcase_05 AC 74 ms
71,480 KB
testcase_06 AC 75 ms
71,224 KB
testcase_07 AC 108 ms
77,156 KB
testcase_08 AC 98 ms
77,068 KB
testcase_09 AC 106 ms
77,152 KB
testcase_10 AC 106 ms
76,888 KB
testcase_11 AC 314 ms
96,580 KB
testcase_12 AC 305 ms
95,776 KB
testcase_13 AC 313 ms
96,304 KB
testcase_14 AC 307 ms
96,312 KB
testcase_15 AC 305 ms
96,416 KB
testcase_16 AC 305 ms
95,628 KB
testcase_17 AC 285 ms
96,548 KB
testcase_18 AC 279 ms
95,992 KB
testcase_19 AC 281 ms
95,808 KB
testcase_20 AC 294 ms
96,612 KB
testcase_21 AC 293 ms
96,384 KB
testcase_22 AC 285 ms
96,292 KB
testcase_23 AC 294 ms
95,720 KB
testcase_24 AC 282 ms
95,688 KB
testcase_25 AC 213 ms
99,276 KB
testcase_26 AC 225 ms
99,216 KB
testcase_27 AC 262 ms
95,488 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,q=map(int,input().split())
a=list(map(int,input().split()))
s=input()
t=list(map(int,input().split()))
l=max(max(a),max(t)).bit_length()
points=[[0]*2 for _ in range(l)]
for i in range(l-1,-1,-1):
    k=2**i
    tmp1=0
    tmp2=1
    for j in range(n):
        if s[j]=='0':
            #bit on
            if a[j]&k:
                continue
            #bit off
            else:
                if tmp1==1:
                    tmp1=0
                    points[i][0]+=k
                if tmp2==1:
                    tmp2=0
                    points[i][1]+=k
        elif s[j]=='1':
            #bit on
            if a[j]&k:
                if tmp1==0:
                    tmp1=1
                    points[i][0]+=k
                if tmp2==0:
                    tmp2=1
                    points[i][1]+=k
            #bit off
            else:
                continue
for val in t:
    tmp=0
    for i in range(l-1,-1,-1):
        #bit on
        if val&(2**i):
            tmp+=points[i][1]
        #bit off
        else:
            tmp+=points[i][0]
    print(tmp)
0