結果

問題 No.2308 [Cherry 5th Tune B] もしかして、真?
ユーザー 倉
提出日時 2023-05-20 09:11:08
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 2,885 bytes
コンパイル時間 312 ms
コンパイル使用メモリ 87,284 KB
実行使用メモリ 142,568 KB
最終ジャッジ日時 2023-08-23 07:17:09
合計ジャッジ時間 24,636 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 103 ms
72,404 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 609 ms
127,216 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 602 ms
141,948 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 618 ms
141,916 KB
testcase_27 AC 613 ms
142,072 KB
testcase_28 AC 614 ms
141,796 KB
testcase_29 AC 600 ms
141,832 KB
testcase_30 AC 601 ms
141,732 KB
testcase_31 AC 403 ms
140,576 KB
testcase_32 AC 407 ms
139,764 KB
testcase_33 AC 407 ms
140,324 KB
testcase_34 AC 424 ms
141,312 KB
testcase_35 WA -
testcase_36 AC 423 ms
141,068 KB
testcase_37 WA -
testcase_38 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from functools import partial
# import pypyjit
# pypyjit.set_param('max_unroll_recursion = -1')

sys.setrecursionlimit(500005)
stdin = sys.stdin

ns = lambda: stdin.readline().strip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nz = lambda: list(map(lambda x: int(x)-1, stdin.readline().split())) # 遅い
printa = partial(print, sep="\n") # printa(*A) で各要素を改行して出力
mod = 1000000007 # 998244353
inf = 10 ** 18

# @maspy / Segment Tree のお勉強(1)
# https://maspypy.com/segment-tree-%E3%81%AE%E3%81%8A%E5%8B%89%E5%BC%B71
from operator import add


class SegTree:
    X_unit = 0
    X_f = add

    def __init__(self, N):
        self.N = N
        self.X = [self.X_unit] * (N + N)

    def build(self, seq):
        for i, x in enumerate(seq, self.N):
            self.X[i] = x
        for i in range(self.N - 1, 0, -1):
            self.X[i] = self.X_f(self.X[i << 1], self.X[i << 1 | 1])

    def set_val(self, i, x):
        i += self.N
        self.X[i] = x
        while i > 1:
            i >>= 1
            self.X[i] = self.X_f(self.X[i << 1], self.X[i << 1 | 1])
    
    def sub_val(self, i, x):
        i += self.N
        self.X[i] -= x
        while i > 1:
            i >>= 1
            self.X[i] = self.X_f(self.X[i << 1], self.X[i << 1 | 1])
    

    def fold(self, L, R):
        """半開区間 [L, R)"""
        L += self.N
        R += self.N
        vL = self.X_unit
        vR = self.X_unit
        while L < R:
            if L & 1:
                vL = self.X_f(vL, self.X[L])
                L += 1
            if R & 1:
                R -= 1
                vR = self.X_f(self.X[R], vR)
            L >>= 1
            R >>= 1
        return self.X_f(vL, vR)
    
    def find_l(self, k):
        id = 1
        while id < self.N:
            if self.X[id << 1] >= k:
                id <<= 1
            else:
                k -= self.X[id << 1]
                id = id << 1 | 1
        return id - self.N
    
    def debug(self):
        print(self.X[self.N:])

def set_size(k):
    ret = 1
    while k >= 2:
        k //= 2
        ret += 1
    return pow(2, ret)

def cal(x, y, o):
    if o == "a":
        return x & y
    elif o == "o":
        return x | y
    elif o == "x":
        return x ^ y
    else:
        return (not x) | y

def solve():
    N = ni()
    N = set_size(N)
    Xseg = SegTree(N)
    Xseg.build([1] * N)
    Yseg = SegTree(N)
    Yseg.build([1] * N)
    X = [1 if i == "True" else 0 for i in ns().split()]
    Y = list(ns().split())
    S = na()
    for s in S:
        yid = Yseg.find_l(s)
        Yseg.sub_val(yid, 1)
        op = Y[yid][0]
        xidl = Xseg.find_l(s)
        xidr = Xseg.find_l(s+1)
        Xseg.sub_val(xidr, 1)
        X[yid] = cal(X[xidl], X[xidr], op)
    print("True" if X[0] else "False")

T = ni()
for _ in range(T):
    solve()
0