結果
問題 | No.1439 Let's Compare!!!! |
ユーザー | rlangevin |
提出日時 | 2023-01-19 21:47:12 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 795 ms / 2,000 ms |
コード長 | 1,609 bytes |
コンパイル時間 | 578 ms |
コンパイル使用メモリ | 86,880 KB |
実行使用メモリ | 122,624 KB |
最終ジャッジ日時 | 2023-09-04 14:48:25 |
合計ジャッジ時間 | 11,390 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 77 ms
71,416 KB |
testcase_01 | AC | 78 ms
71,236 KB |
testcase_02 | AC | 77 ms
71,276 KB |
testcase_03 | AC | 77 ms
71,568 KB |
testcase_04 | AC | 82 ms
75,360 KB |
testcase_05 | AC | 78 ms
71,276 KB |
testcase_06 | AC | 78 ms
71,268 KB |
testcase_07 | AC | 153 ms
78,232 KB |
testcase_08 | AC | 160 ms
78,312 KB |
testcase_09 | AC | 131 ms
77,832 KB |
testcase_10 | AC | 783 ms
121,544 KB |
testcase_11 | AC | 795 ms
122,404 KB |
testcase_12 | AC | 743 ms
121,468 KB |
testcase_13 | AC | 771 ms
122,624 KB |
testcase_14 | AC | 784 ms
122,496 KB |
testcase_15 | AC | 777 ms
122,420 KB |
testcase_16 | AC | 755 ms
122,440 KB |
testcase_17 | AC | 782 ms
122,360 KB |
testcase_18 | AC | 706 ms
122,180 KB |
ソースコード
import sys readline = sys.stdin.readline class Fenwick_Tree: def __init__(self, n): self._n = n self.data = [0] * n def add(self, p, x): assert 0 <= p < self._n p += 1 while p <= self._n: self.data[p - 1] += x p += p & -p def sum(self, l, r): assert 0 <= l <= r <= self._n return self._sum(r) - self._sum(l) def _sum(self, r): s = 0 while r > 0: s += self.data[r - 1] r -= r & -r return s def get(self, k): k += 1 x, r = 0, 1 while r < self._n: r <<= 1 len = r while len: if x + len - 1 < self._n: if self.data[x + len - 1] < k: k -= self.data[x + len - 1] x += len len >>= 1 return x N = 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) - 1 y = int(y) BIT.add(x, -int(S[x] == T[x])) if c == "S": S[x] = y else: T[x] = y BIT.add(x, int(S[x] == T[x])) yes = 0 no = N + 1 while no - yes != 1: mid = (yes + no)//2 if BIT.sum(0, mid) == mid: yes = mid else: no = mid if yes == N: print("=") elif S[yes] > T[yes]: print(">") else: print("<")