結果
| 問題 |
No.2308 [Cherry 5th Tune B] もしかして、真?
|
| コンテスト | |
| ユーザー |
sasa8uyauya
|
| 提出日時 | 2025-02-23 14:49:42 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 821 ms / 2,000 ms |
| コード長 | 1,054 bytes |
| コンパイル時間 | 504 ms |
| コンパイル使用メモリ | 82,584 KB |
| 実行使用メモリ | 150,580 KB |
| 最終ジャッジ日時 | 2025-02-23 14:50:15 |
| 合計ジャッジ時間 | 31,913 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 39 |
ソースコード
class SegTree:
def __init__(self,n):
self.L=1<<(len(bin(n))-2)
self.q=[0]*self.L*2
return
def add(self,p,x):
p+=self.L
self.q[p]+=x
p//=2
while p>0:
self.q[p]=self.q[p*2+0]+self.q[p*2+1]
p//=2
return
def bisect(self,c):
a=0
p=1
while p<self.L:
if a+self.q[p*2+0]<c:
a+=self.q[p*2+0]
p=p*2+1
else:
p=p*2+0
return p-self.L
T=int(input())
for _ in range(T):
n=int(input())
x=[int(x=="True") for x in input().split()]
y=input().split()
s=list(map(int,input().split()))
z=[]
for i in range(n-1):
z+=[x[i],y[i]]
z+=[x[-1]]
q=SegTree(len(z))
for i in range(len(z)):
q.add(i,1)
for v in s:
p1=q.bisect(v*2-1)
p2=q.bisect(v*2)
p3=q.bisect(v*2+1)
l=z[p1]
o=z[p2]
r=z[p3]
q.add(p1,-1)
q.add(p2,-1)
q.add(p3,-1)
if o=="and":
a=l&r
if o=="or":
a=l|r
if o=="xor":
a=l^r
if o=="imp":
a=(not l)|r
z[p1]=a
q.add(p1,1)
print(["False","True"][z[0]])
sasa8uyauya