結果

問題 No.1439 Let's Compare!!!!
ユーザー nephrologistnephrologist
提出日時 2021-03-26 22:17:55
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,862 ms / 2,000 ms
コード長 2,392 bytes
コンパイル時間 560 ms
コンパイル使用メモリ 86,928 KB
実行使用メモリ 126,216 KB
最終ジャッジ日時 2023-08-19 15:22:28
合計ジャッジ時間 14,538 ms
ジャッジサーバーID
(参考情報)
judge10 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,420 KB
testcase_01 AC 75 ms
70,936 KB
testcase_02 AC 75 ms
71,216 KB
testcase_03 AC 76 ms
71,376 KB
testcase_04 AC 78 ms
71,384 KB
testcase_05 AC 78 ms
71,332 KB
testcase_06 AC 76 ms
71,144 KB
testcase_07 AC 215 ms
81,280 KB
testcase_08 AC 263 ms
80,856 KB
testcase_09 AC 176 ms
78,668 KB
testcase_10 AC 1,167 ms
113,156 KB
testcase_11 AC 1,260 ms
119,352 KB
testcase_12 AC 997 ms
114,324 KB
testcase_13 AC 1,194 ms
113,796 KB
testcase_14 AC 1,699 ms
119,256 KB
testcase_15 AC 1,320 ms
126,216 KB
testcase_16 AC 1,049 ms
116,848 KB
testcase_17 AC 1,862 ms
105,344 KB
testcase_18 AC 574 ms
102,596 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from heapq import heappop, heappush

n = int(input())
s = list(map(int, list(input())))
t = list(map(int, list(input())))
q = int(input())


s_bigger = []

s_bigger_del = []
t_bigger = []
t_bigger_del = []


for i in range(n):
    if s[i] > t[i]:
        heappush(s_bigger, i * 10 + s[i])
    elif s[i] < t[i]:
        heappush(t_bigger, i * 10 + t[i])

for _ in range(q):
    # delのものを消す
    # while s_bigger_del:
    #     if s_bigger[0] == s_bigger_del[0]:
    #         heappop(s_bigger)
    #         heappop(s_bigger_del)
    #     else:
    #         break
    # while t_bigger_del:
    #     if t_bigger[0] == t_bigger_del[0]:
    #         heappop(t_bigger)
    #         heappop(t_bigger_del)
    #     else:
    #         break
    c, x, y = input().split()
    x = int(x)
    y = int(y)
    if c == "S":
        if s[x - 1] > t[x - 1]:
            heappush(s_bigger_del, (x - 1) * 10 + s[x - 1])
        elif s[x - 1] < t[x - 1]:
            heappush(t_bigger_del, (x - 1) * 10 + t[x - 1])
        s[x - 1] = y
        if s[x - 1] > t[x - 1]:
            heappush(s_bigger, (x - 1) * 10 + s[x - 1])
        elif t[x - 1] > s[x - 1]:
            heappush(t_bigger, (x - 1) * 10 + t[x - 1])
    else:
        if s[x - 1] > t[x - 1]:
            heappush(s_bigger_del, (x - 1) * 10 + s[x - 1])
        elif s[x - 1] < t[x - 1]:
            heappush(t_bigger_del, (x - 1) * 10 + t[x - 1])
        t[x - 1] = y
        if s[x - 1] > t[x - 1]:
            heappush(s_bigger, (x - 1) * 10 + s[x - 1])
        elif t[x - 1] > s[x - 1]:
            heappush(t_bigger, (x - 1) * 10 + t[x - 1])
    while s_bigger_del:
        if s_bigger[0] == s_bigger_del[0]:
            heappop(s_bigger)
            heappop(s_bigger_del)
        else:
            break
    while t_bigger_del:
        if t_bigger[0] == t_bigger_del[0]:
            heappop(t_bigger)
            heappop(t_bigger_del)
        else:
            break

    if not s_bigger and not t_bigger:
        print("=")
    elif not s_bigger:
        print("<")
    elif not t_bigger:
        print(">")
    else:
        ttt = t_bigger[0] // 10
        sss = s_bigger[0] // 10
        if sss < ttt:
            print(">")
        else:
            print("<")
    # print("s", "".join(map(str, s)))
    # print("t", "".join(map(str, t)))
    # print("s", s_bigger, s_bigger_del)
    # print("t", t_bigger, t_bigger_del)
0