結果

問題 No.2308 [Cherry 5th Tune B] もしかして、真?
ユーザー titiatitia
提出日時 2023-05-19 23:44:54
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,026 ms / 2,000 ms
コード長 1,973 bytes
コンパイル時間 305 ms
コンパイル使用メモリ 87,232 KB
実行使用メモリ 153,152 KB
最終ジャッジ日時 2023-08-23 01:38:49
合計ジャッジ時間 37,280 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,460 KB
testcase_01 AC 775 ms
125,660 KB
testcase_02 AC 892 ms
148,288 KB
testcase_03 AC 817 ms
127,992 KB
testcase_04 AC 813 ms
125,956 KB
testcase_05 AC 877 ms
126,300 KB
testcase_06 AC 884 ms
153,152 KB
testcase_07 AC 939 ms
149,704 KB
testcase_08 AC 938 ms
132,324 KB
testcase_09 AC 917 ms
131,784 KB
testcase_10 AC 863 ms
135,584 KB
testcase_11 AC 950 ms
148,048 KB
testcase_12 AC 945 ms
150,328 KB
testcase_13 AC 949 ms
151,252 KB
testcase_14 AC 952 ms
150,460 KB
testcase_15 AC 951 ms
150,104 KB
testcase_16 AC 943 ms
150,288 KB
testcase_17 AC 960 ms
150,680 KB
testcase_18 AC 966 ms
149,720 KB
testcase_19 AC 949 ms
149,868 KB
testcase_20 AC 946 ms
151,496 KB
testcase_21 AC 1,005 ms
148,224 KB
testcase_22 AC 1,021 ms
148,180 KB
testcase_23 AC 1,015 ms
147,996 KB
testcase_24 AC 1,026 ms
148,148 KB
testcase_25 AC 995 ms
148,156 KB
testcase_26 AC 992 ms
148,128 KB
testcase_27 AC 1,025 ms
148,196 KB
testcase_28 AC 1,007 ms
148,116 KB
testcase_29 AC 998 ms
148,060 KB
testcase_30 AC 1,009 ms
148,268 KB
testcase_31 AC 557 ms
151,340 KB
testcase_32 AC 554 ms
151,308 KB
testcase_33 AC 569 ms
151,364 KB
testcase_34 AC 639 ms
149,560 KB
testcase_35 AC 635 ms
149,636 KB
testcase_36 AC 628 ms
149,344 KB
testcase_37 AC 234 ms
79,144 KB
testcase_38 AC 963 ms
143,000 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

    
            
    

    
0