結果
問題 | No.1439 Let's Compare!!!! |
ユーザー |
![]() |
提出日時 | 2023-01-19 21:47:12 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 636 ms / 2,000 ms |
コード長 | 1,609 bytes |
コンパイル時間 | 287 ms |
コンパイル使用メモリ | 82,456 KB |
実行使用メモリ | 102,128 KB |
最終ジャッジ日時 | 2024-06-22 13:06:38 |
合計ジャッジ時間 | 7,914 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 17 |
ソースコード
import sysreadline = sys.stdin.readlineclass Fenwick_Tree:def __init__(self, n):self._n = nself.data = [0] * ndef add(self, p, x):assert 0 <= p < self._np += 1while p <= self._n:self.data[p - 1] += xp += p & -pdef sum(self, l, r):assert 0 <= l <= r <= self._nreturn self._sum(r) - self._sum(l)def _sum(self, r):s = 0while r > 0:s += self.data[r - 1]r -= r & -rreturn sdef get(self, k):k += 1x, r = 0, 1while r < self._n:r <<= 1len = rwhile len:if x + len - 1 < self._n:if self.data[x + len - 1] < k:k -= self.data[x + len - 1]x += lenlen >>= 1return xN = int(readline())S = list(input().rstrip())T = list(input().rstrip())S = list(map(int, S))T = list(map(int, T))Q = int(readline())BIT = Fenwick_Tree(N)for i in range(N):BIT.add(i, int(S[i] == T[i]))for _ in range(Q):c, x, y = readline().split()x = int(x) - 1y = int(y)BIT.add(x, -int(S[x] == T[x]))if c == "S":S[x] = yelse:T[x] = yBIT.add(x, int(S[x] == T[x]))yes = 0no = N + 1while no - yes != 1:mid = (yes + no)//2if BIT.sum(0, mid) == mid:yes = midelse:no = midif yes == N:print("=")elif S[yes] > T[yes]:print(">")else:print("<")