結果
問題 | No.2308 [Cherry 5th Tune B] もしかして、真? |
ユーザー | titia |
提出日時 | 2023-05-19 23:44:54 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,092 ms / 2,000 ms |
コード長 | 1,973 bytes |
コンパイル時間 | 286 ms |
コンパイル使用メモリ | 82,144 KB |
実行使用メモリ | 153,628 KB |
最終ジャッジ日時 | 2024-12-20 02:22:32 |
合計ジャッジ時間 | 37,537 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 39 |
ソースコード
import sys input = sys.stdin.readline def calc(x,op,y): if op=="and": return x & y if op =="or": return x|y if op =="xor": return x^y if op=="imp": return (x^1)|y def update(v,w): # index vにwを加える while v<=LEN: BIT[v]+=w v+=(v&(-v)) # v&(-v)で、最も下の立っているビット. 自分を含む大きなノードへ. たとえばv=3→v=4 def getvalue(v): # [1,v]の区間の和を求める if v<0: return 0 ANS=0 while v!=0: ANS+=BIT[v] v-=(v&(-v)) # 自分より小さい自分の和を構成するノードへ. たとえばv=14→v=12へ return ANS T=int(input()) for tests in range(T): N=int(input()) X=input().split() Y=input().split() S=list(map(int,input().split())) for i in range(N): if X[i]=="True": X[i]=1 else: X[i]=0 LIST=[] for i in range(N): LIST.append(X[i]) if i<len(Y): LIST.append(Y[i]) LEFT=[i-1 for i in range(len(LIST))] RIGHT=[i+1 for i in range(len(LIST))] LEN=len(LIST)+3 BIT=[0]*(LEN+1) #print(LIST) for s in S: OK=len(LIST)-1 NG=-1 while OK>NG+1: mid=(OK+NG)//2 if mid//2+1-getvalue(mid)>=s: OK=mid else: NG=mid x=OK #print("!",OK,LIST) a=LIST[x] b=LIST[RIGHT[x]] c=LIST[RIGHT[RIGHT[x]]] ret=calc(a,b,c) #print(a,b,c,x) LIST[x]=ret LIST[RIGHT[x]]=-1 LIST[RIGHT[RIGHT[x]]]=-1 #print(LIST) update(RIGHT[RIGHT[x]],1) RIGHT[x]=RIGHT[RIGHT[RIGHT[x]]] #update(RIGHT[RIGHT[x]],1) #print(LIST) for x in LIST: if x!=-1: if x==1: print("True") else: print("False") break