結果
問題 |
No.2308 [Cherry 5th Tune B] もしかして、真?
|
ユーザー |
![]() |
提出日時 | 2023-05-21 12:28:48 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,120 bytes |
コンパイル時間 | 375 ms |
コンパイル使用メモリ | 82,092 KB |
実行使用メモリ | 130,556 KB |
最終ジャッジ日時 | 2024-12-21 19:13:52 |
合計ジャッジ時間 | 47,125 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 16 WA * 17 RE * 6 |
ソースコード
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 = 1 ub = N + 1 while ub - lb > 1: mid = (lb + ub) // 2 if bit.sum(mid) <= x: lb = mid else: ub = mid return lb 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) for i in range(1, N + 1): bit.add(i, 1) for s in S: r = search(s) 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) print(X[r])