結果

問題 No.1439 Let's Compare!!!!
ユーザー 👑 tamatotamato
提出日時 2021-03-26 21:37:43
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 668 ms / 2,000 ms
コード長 2,380 bytes
コンパイル時間 1,447 ms
コンパイル使用メモリ 86,992 KB
実行使用メモリ 111,924 KB
最終ジャッジ日時 2023-08-19 15:12:28
合計ジャッジ時間 9,034 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 67 ms
71,556 KB
testcase_01 AC 65 ms
71,864 KB
testcase_02 AC 65 ms
71,620 KB
testcase_03 AC 65 ms
71,800 KB
testcase_04 AC 65 ms
71,576 KB
testcase_05 AC 64 ms
71,556 KB
testcase_06 AC 65 ms
71,756 KB
testcase_07 AC 151 ms
79,332 KB
testcase_08 AC 180 ms
80,792 KB
testcase_09 AC 118 ms
78,776 KB
testcase_10 AC 659 ms
108,724 KB
testcase_11 AC 668 ms
111,924 KB
testcase_12 AC 577 ms
110,668 KB
testcase_13 AC 651 ms
108,676 KB
testcase_14 AC 647 ms
108,172 KB
testcase_15 AC 622 ms
110,088 KB
testcase_16 AC 569 ms
107,724 KB
testcase_17 AC 569 ms
107,340 KB
testcase_18 AC 286 ms
99,476 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

    class Bit:
        def __init__(self, n):
            self.size = n
            self.tree = [0] * (n + 1)

        def sum(self, i):
            s = 0
            while i > 0:
                s += self.tree[i]
                i -= i & -i
            return s

        def add(self, i, x):
            while i <= self.size:
                self.tree[i] += x
                i += i & -i

        def lower_bound(self, w):
            if w <= 0:
                return 0
            x = 0
            k = 1 << (self.size.bit_length() - 1)
            while k:
                if x + k <= self.size and self.tree[x + k] < w:
                    w -= self.tree[x + k]
                    x += k
                k >>= 1
            return x + 1

    N = int(input())
    S = input().rstrip('\n')
    T = input().rstrip('\n')
    S = [s for s in S]
    T = [t for t in T]
    bit_S = Bit(N)
    bit_T = Bit(N)
    for i in range(N):
        s = int(S[i])
        t = int(T[i])
        if s > t:
            bit_S.add(i+1, 1)
        elif s < t:
            bit_T.add(i+1, 1)
    for _ in range(int(input())):
        c, x, y = input().split()
        x = int(x)
        S_large = 0
        s = int(S[x - 1])
        t = int(T[x - 1])
        if s > t:
            S_large = 1
        elif s < t:
            S_large = -1
        if c == "S":
            S[x-1] = y
        else:
            T[x-1] = y
        s = int(S[x-1])
        t = int(T[x-1])
        if s > t:
            if S_large == 1:
                pass
            elif S_large == 0:
                bit_S.add(x, 1)
            else:
                bit_S.add(x, 1)
                bit_T.add(x, -1)
        elif s < t:
            if S_large == 1:
                bit_T.add(x, 1)
                bit_S.add(x, -1)
            elif S_large == 0:
                bit_T.add(x, 1)
            else:
                pass
        else:
            if S_large == 1:
                bit_S.add(x, -1)
            elif S_large == 0:
                pass
            else:
                bit_T.add(x, -1)
        js = bit_S.lower_bound(1)
        jt = bit_T.lower_bound(1)
        if js < jt:
            print(">")
        elif js > jt:
            print("<")
        else:
            print("=")


if __name__ == '__main__':
    main()
0