結果

問題 No.2308 [Cherry 5th Tune B] もしかして、真?
ユーザー ntudantuda
提出日時 2023-05-21 12:48:02
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,242 ms / 2,000 ms
コード長 1,178 bytes
コンパイル時間 639 ms
コンパイル使用メモリ 87,236 KB
実行使用メモリ 134,820 KB
最終ジャッジ日時 2023-09-15 14:44:54
合計ジャッジ時間 47,530 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 66 ms
71,140 KB
testcase_01 AC 971 ms
105,816 KB
testcase_02 AC 1,021 ms
109,208 KB
testcase_03 AC 992 ms
114,376 KB
testcase_04 AC 949 ms
105,416 KB
testcase_05 AC 1,076 ms
112,752 KB
testcase_06 AC 972 ms
116,196 KB
testcase_07 AC 1,120 ms
122,120 KB
testcase_08 AC 1,206 ms
125,336 KB
testcase_09 AC 1,067 ms
124,360 KB
testcase_10 AC 1,112 ms
105,360 KB
testcase_11 AC 1,173 ms
120,776 KB
testcase_12 AC 1,138 ms
120,716 KB
testcase_13 AC 1,089 ms
113,700 KB
testcase_14 AC 1,141 ms
114,452 KB
testcase_15 AC 1,131 ms
113,908 KB
testcase_16 AC 1,183 ms
119,820 KB
testcase_17 AC 1,121 ms
117,736 KB
testcase_18 AC 1,115 ms
116,988 KB
testcase_19 AC 1,107 ms
114,084 KB
testcase_20 AC 1,086 ms
113,768 KB
testcase_21 AC 1,101 ms
134,432 KB
testcase_22 AC 1,194 ms
134,452 KB
testcase_23 AC 1,176 ms
134,820 KB
testcase_24 AC 1,116 ms
134,596 KB
testcase_25 AC 1,178 ms
134,444 KB
testcase_26 AC 1,186 ms
133,432 KB
testcase_27 AC 1,196 ms
134,756 KB
testcase_28 AC 1,158 ms
134,656 KB
testcase_29 AC 1,242 ms
134,652 KB
testcase_30 AC 1,147 ms
134,752 KB
testcase_31 AC 913 ms
130,772 KB
testcase_32 AC 930 ms
130,964 KB
testcase_33 AC 907 ms
132,540 KB
testcase_34 AC 914 ms
132,040 KB
testcase_35 AC 938 ms
133,404 KB
testcase_36 AC 973 ms
132,220 KB
testcase_37 AC 426 ms
84,680 KB
testcase_38 AC 1,151 ms
112,872 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)

    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s

    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i

def search(x):
    lb = 0
    ub = N
    while ub - lb > 1:
        mid = (lb + ub) // 2
        if bit.sum(mid) <= x - 1:
            lb = mid
        else:
            ub = mid
    return lb + 1

T = int(input())
for t in range(T):
    N = int(input())
    X = [True if x == "True" else False for x in input().split()]
    Y = input().split()
    S = list(map(int, input().split()))
    bit = Bit(N + 1)
    B = [1] * (N + 1)
    for i in range(1, N + 1):
        bit.add(i, 1)

    for s in S:
        r = search(s+1) - 1
        l = search(s) - 1
        if Y[l] == "and":
            X[r] &= X[l]
        elif Y[l] == "or":
            X[r] |= X[l]
        elif Y[l] == "xor":
            X[r] ^= X[l]
        else:
            if X[l] == False:
                X[r] = True
        bit.add(l + 1, -1)
        B[l + 1] -= 1
    print(X[r])
0