結果
問題 | No.2308 [Cherry 5th Tune B] もしかして、真? |
ユーザー | 倉 |
提出日時 | 2023-05-20 09:14:44 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 591 ms / 2,000 ms |
コード長 | 2,921 bytes |
コンパイル時間 | 157 ms |
コンパイル使用メモリ | 81,884 KB |
実行使用メモリ | 139,976 KB |
最終ジャッジ日時 | 2024-06-01 05:01:07 |
合計ジャッジ時間 | 22,088 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 50 ms
56,872 KB |
testcase_01 | AC | 514 ms
110,104 KB |
testcase_02 | AC | 503 ms
117,108 KB |
testcase_03 | AC | 486 ms
114,524 KB |
testcase_04 | AC | 480 ms
117,492 KB |
testcase_05 | AC | 546 ms
124,464 KB |
testcase_06 | AC | 521 ms
125,836 KB |
testcase_07 | AC | 554 ms
127,864 KB |
testcase_08 | AC | 575 ms
132,976 KB |
testcase_09 | AC | 537 ms
132,000 KB |
testcase_10 | AC | 543 ms
111,232 KB |
testcase_11 | AC | 549 ms
127,192 KB |
testcase_12 | AC | 562 ms
126,456 KB |
testcase_13 | AC | 559 ms
128,236 KB |
testcase_14 | AC | 553 ms
126,904 KB |
testcase_15 | AC | 569 ms
128,936 KB |
testcase_16 | AC | 563 ms
128,268 KB |
testcase_17 | AC | 564 ms
128,564 KB |
testcase_18 | AC | 557 ms
126,812 KB |
testcase_19 | AC | 566 ms
116,240 KB |
testcase_20 | AC | 551 ms
126,352 KB |
testcase_21 | AC | 566 ms
139,944 KB |
testcase_22 | AC | 561 ms
139,968 KB |
testcase_23 | AC | 574 ms
139,568 KB |
testcase_24 | AC | 568 ms
139,716 KB |
testcase_25 | AC | 555 ms
139,976 KB |
testcase_26 | AC | 561 ms
139,892 KB |
testcase_27 | AC | 591 ms
139,704 KB |
testcase_28 | AC | 580 ms
139,584 KB |
testcase_29 | AC | 557 ms
139,956 KB |
testcase_30 | AC | 565 ms
139,604 KB |
testcase_31 | AC | 363 ms
138,476 KB |
testcase_32 | AC | 358 ms
137,988 KB |
testcase_33 | AC | 356 ms
138,312 KB |
testcase_34 | AC | 378 ms
139,132 KB |
testcase_35 | AC | 372 ms
139,660 KB |
testcase_36 | AC | 366 ms
138,756 KB |
testcase_37 | AC | 230 ms
79,272 KB |
testcase_38 | AC | 565 ms
128,156 KB |
ソースコード
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) # print(op, xidl, xidr, X) X[xidl] = cal(X[xidl], X[xidr], op) print("True" if X[0] else "False") T = ni() for _ in range(T): solve()