結果

問題 No.1439 Let's Compare!!!!
ユーザー gorugo30gorugo30
提出日時 2021-05-08 17:45:31
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,090 ms / 2,000 ms
コード長 1,373 bytes
コンパイル時間 600 ms
コンパイル使用メモリ 81,812 KB
実行使用メモリ 100,792 KB
最終ジャッジ日時 2023-10-16 23:34:09
合計ジャッジ時間 12,611 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
53,568 KB
testcase_01 AC 35 ms
53,568 KB
testcase_02 AC 35 ms
53,568 KB
testcase_03 AC 36 ms
53,568 KB
testcase_04 AC 40 ms
59,400 KB
testcase_05 AC 37 ms
53,568 KB
testcase_06 AC 35 ms
53,568 KB
testcase_07 AC 99 ms
76,972 KB
testcase_08 AC 113 ms
76,824 KB
testcase_09 AC 92 ms
76,384 KB
testcase_10 AC 1,018 ms
97,368 KB
testcase_11 AC 1,090 ms
100,792 KB
testcase_12 AC 1,052 ms
99,876 KB
testcase_13 AC 1,006 ms
97,772 KB
testcase_14 AC 1,028 ms
97,608 KB
testcase_15 AC 975 ms
100,448 KB
testcase_16 AC 918 ms
95,984 KB
testcase_17 AC 897 ms
95,984 KB
testcase_18 AC 842 ms
95,984 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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("<")
0