結果
問題 | No.2308 [Cherry 5th Tune B] もしかして、真? |
ユーザー |
![]() |
提出日時 | 2023-05-19 23:26:46 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,766 bytes |
コンパイル時間 | 214 ms |
コンパイル使用メモリ | 12,928 KB |
実行使用メモリ | 72,020 KB |
最終ジャッジ日時 | 2024-12-20 02:02:50 |
合計ジャッジ時間 | 70,146 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 14 WA * 16 TLE * 9 |
ソースコード
import sysinput = sys.stdin.readlinedef calc(x,op,y):if op=="and":return x & yif op =="or":return x|yif op =="xor":return x^yif op=="imp":return (x^1)|ydef update(v,w): # index vにwを加えるwhile v<=LEN:BIT[v]+=wv+=(v&(-v)) # v&(-v)で、最も下の立っているビット. 自分を含む大きなノードへ. たとえばv=3→v=4def getvalue(v): # [1,v]の区間の和を求めるANS=0while v!=0:ANS+=BIT[v]v-=(v&(-v)) # 自分より小さい自分の和を構成するノードへ. たとえばv=14→v=12へreturn ANST=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]=1else:X[i]=0LIST=[]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)+3BIT=[0]*(LEN+1)#print(LIST)for s in S:plus=getvalue(s-1)x=(s-1+plus)*2while LIST[x]==-1:x=RIGHT[RIGHT[x]]a=LIST[x]b=LIST[RIGHT[x]]c=LIST[RIGHT[RIGHT[x]]]ret=calc(a,b,c)#print(a,b,c,x)LIST[x]=retLIST[RIGHT[x]]=-1LIST[RIGHT[RIGHT[x]]]=-1#print(LIST)RIGHT[x]=RIGHT[RIGHT[RIGHT[x]]]update(s,1)#print(LIST)for x in LIST:if x!=-1:if x==1:print("True")else:print("False")break