結果
問題 |
No.1245 ANDORゲーム(calc)
|
ユーザー |
![]() |
提出日時 | 2020-10-03 12:56:10 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 470 ms / 2,000 ms |
コード長 | 1,201 bytes |
コンパイル時間 | 150 ms |
コンパイル使用メモリ | 82,228 KB |
実行使用メモリ | 100,820 KB |
最終ジャッジ日時 | 2024-07-18 04:18:56 |
合計ジャッジ時間 | 8,487 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 25 |
ソースコード
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()