結果

問題 No.1245 ANDORゲーム(calc)
コンテスト
ユーザー titia
提出日時 2020-10-03 01:20:29
言語 Python3
(3.14.3 + numpy 2.4.4 + scipy 1.17.1)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
AC  
実行時間 1,545 ms / 2,000 ms
コード長 991 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 445 ms
コンパイル使用メモリ 20,700 KB
実行使用メモリ 56,268 KB
最終ジャッジ日時 2026-04-01 17:54:48
合計ジャッジ時間 26,807 ms
ジャッジサーバーID
(参考情報)
judge3_1 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import sys
input = sys.stdin.readline

N,Q=map(int,input().split())
A=list(map(int,input().split()))
S=input().strip()
T=list(map(int,input().split()))

X=[-1]*31
X2=[-1]*31
score=0

for i in range(N):
    a=A[i]
    s=int(S[i])
    for j in range(31):
        if a & (1<<j) == 0:
            if s==0:
                if X[j]==-1:
                    X[j]=0
                    X2[j]=0
                elif X2[j]==1:
                    X2[j]=0
                    score+=1<<j
        else:
            if s==1:
                if X[j]==-1:
                    X[j]=1
                    X2[j]=1
                elif X2[j]==0:
                    X2[j]=1
                    score+=1<<j
    #print(X)

for t in T:
    score2=0
    for j in range(31):
        if X[j]==0:
            if t & (1<<j) !=0:
                score2+=1<<j
        elif X[j]==1:
            if t & (1<<j) ==0:
                score2+=1<<j

    print(score+score2)
            
                
            
         
0