結果
| 問題 |
No.1439 Let's Compare!!!!
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-05-08 17:45:31 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 1,175 ms / 2,000 ms |
| コード長 | 1,373 bytes |
| コンパイル時間 | 814 ms |
| コンパイル使用メモリ | 82,280 KB |
| 実行使用メモリ | 100,808 KB |
| 最終ジャッジ日時 | 2024-09-16 23:16:27 |
| 合計ジャッジ時間 | 12,794 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge6 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 17 |
ソースコード
class Fenwick:
def __init__(self, n):
self.n = n
self.data = [0] * (n + 1)
self.depth = n.bit_length()
def getsum(self, i): # 0-indexed [0: i)
res = 0
while i > 0:
res += self.data[i]
i -= i & -i
return res
def add(self, i, x): # 0-indexed
i += 1
while i <= self.n:
self.data[i] += x
i += i & -i
N = int(input())
S = list(input())
T = list(input())
BIT = Fenwick(N)
for i in range(N):
if S[i] != T[i]:
BIT.add(i, 1)
Q = int(input())
for i in range(Q):
c, x, y = input().split()
x = int(x) - 1
if c == "S":
if S[x] == T[x]:
S[x] = y
if S[x] != T[x]:
BIT.add(x, 1)
else:
S[x] = y
if S[x] == T[x]:
BIT.add(x, -1)
else:
if S[x] == T[x]:
T[x] = y
if S[x] != T[x]:
BIT.add(x, 1)
else:
T[x] = y
if S[x] == T[x]:
BIT.add(x, -1)
st = 0
en = N + 1
while en - st > 1:
mid = (en + st) // 2
if BIT.getsum(mid) > 0:
en = mid
else:
st = mid
if en == N + 1:
print("=")
else:
if S[en - 1] > T[en - 1]:
print(">")
else:
print("<")