結果
| 問題 | No.1245 ANDORゲーム(calc) |
| コンテスト | |
| ユーザー |
👑 Kazun
|
| 提出日時 | 2021-06-16 04:31:55 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 417 ms / 2,000 ms |
| コード長 | 893 bytes |
| コンパイル時間 | 384 ms |
| コンパイル使用メモリ | 82,200 KB |
| 実行使用メモリ | 112,352 KB |
| 最終ジャッジ日時 | 2024-12-29 10:26:24 |
| 合計ジャッジ時間 | 10,365 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 25 |
ソースコード
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)))
Kazun