結果
問題 | No.1439 Let's Compare!!!! |
ユーザー |
👑 |
提出日時 | 2022-01-18 05:14:57 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 833 ms / 2,000 ms |
コード長 | 2,159 bytes |
コンパイル時間 | 386 ms |
コンパイル使用メモリ | 82,512 KB |
実行使用メモリ | 101,376 KB |
最終ジャッジ日時 | 2024-11-23 13:15:40 |
合計ジャッジ時間 | 10,210 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 17 |
ソースコード
class SegTree():def __init__(self, n, e, ope, lst=[]):self.N0 = 2 ** (n - 1).bit_length()self.e = eself.ope = opeself.data = [e] * (2 * self.N0)if lst:for i in range(n):self.data[self.N0 + i] = lst[i]for i in range(self.N0 - 1, 0, -1):self.data[i] = self.ope(self.data[2 * i], self.data[2 * i + 1])def f5(self):for i in range(self.N0 - 1, 0, -1):self.data[i] = self.ope(self.data[2 * i], self.data[2 * i + 1])def update(self, i, x): #a_iの値をxに更新i += self.N0self.data[i] = xwhile i > 1:i >>= 1self.data[i] = self.ope(self.data[2 * i], self.data[2 * i + 1])def add(self, i, x):self.update(i, x + self.get(i))def query(self, l, r): #区間[l, r)での演算結果if r <= l:return self.eres = self.el += self.N0r += self.N0while l < r:if l & 1:res = self.ope(res, self.data[l])l += 1if r & 1:r -= 1res = self.ope(self.data[r], res)l >>= 1r >>= 1return resdef get(self, i): #a_iの値を返すreturn self.data[self.N0 + i]e = 0def ope(x, y):if x * y == 0:return x + yelse:return xn = int(input())S = list(map(int, input()))T = list(map(int, input()))lst = []for s, t in zip(S, T):if s < t:lst.append(1)elif s == t:lst.append(0)else:lst.append(-1)seg = SegTree(n, e, ope, lst)q = int(input())for _ in range(q):c, x, y = input().split()x = int(x) - 1y = int(y)if c == "T":T[x] = yelse:S[x] = yif T[x] > S[x]:seg.update(x, 1)elif T[x] == S[x]:seg.update(x, 0)else:seg.update(x, -1)ans = seg.query(0, n)if ans == 1:print("<")elif ans == 0:print("=")else:print(">")