結果

問題 No.1245 ANDORゲーム(calc)
ユーザー uni_pythonuni_python
提出日時 2020-10-03 12:56:10
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 546 ms / 2,000 ms
コード長 1,201 bytes
コンパイル時間 292 ms
コンパイル使用メモリ 86,912 KB
実行使用メモリ 99,468 KB
最終ジャッジ日時 2023-09-25 05:04:43
合計ジャッジ時間 10,592 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
71,276 KB
testcase_01 AC 69 ms
71,348 KB
testcase_02 AC 70 ms
71,364 KB
testcase_03 AC 69 ms
71,364 KB
testcase_04 AC 71 ms
71,564 KB
testcase_05 AC 71 ms
71,300 KB
testcase_06 AC 73 ms
71,416 KB
testcase_07 AC 95 ms
77,088 KB
testcase_08 AC 89 ms
77,092 KB
testcase_09 AC 97 ms
77,572 KB
testcase_10 AC 90 ms
77,064 KB
testcase_11 AC 546 ms
95,868 KB
testcase_12 AC 465 ms
96,124 KB
testcase_13 AC 470 ms
95,876 KB
testcase_14 AC 423 ms
95,668 KB
testcase_15 AC 424 ms
95,832 KB
testcase_16 AC 457 ms
95,536 KB
testcase_17 AC 411 ms
96,388 KB
testcase_18 AC 358 ms
95,720 KB
testcase_19 AC 342 ms
96,160 KB
testcase_20 AC 431 ms
95,748 KB
testcase_21 AC 369 ms
95,908 KB
testcase_22 AC 346 ms
95,792 KB
testcase_23 AC 421 ms
95,840 KB
testcase_24 AC 448 ms
96,128 KB
testcase_25 AC 245 ms
99,268 KB
testcase_26 AC 284 ms
99,468 KB
testcase_27 AC 354 ms
95,564 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N,Q=MI()
    A=LI()
    S=input()
    T=LI()
    
    M=60
    
    # 各桁について,元が0,1の時のscoreを求めておく
    zero=[0]*M
    one =[0]*M
    
    def calc(st):
        for i in range(M):#右からi桁目
            now=st
            score=0
            diff=pow(2,i)
            for j,a in enumerate(A):
                aa=(a>>i)&1
                
                # print(a,j)
                if S[j]=="0":
                    nxt=now & aa
                else:
                    nxt=now | aa
                    
                if now!=nxt:
                    score+=diff
                now=nxt
            if st==0:
                zero[i]=score
            else:
                one[i]=score
                
    calc(0)
    calc(1)
    for t in T:
        score=0
        for i in range(M):
            aa=(t>>i)&1
            if aa==0:
                score+=zero[i]
            else:
                score+=one[i]
                
        print(score)
            
        
        


            


main()
0