結果

問題 No.1439 Let's Compare!!!!
コンテスト
ユーザー lloyz
提出日時 2022-02-15 19:07:17
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 485 ms / 2,000 ms
コード長 911 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 125 ms
コンパイル使用メモリ 85,332 KB
実行使用メモリ 124,968 KB
最終ジャッジ日時 2026-03-18 17:35:06
合計ジャッジ時間 5,413 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

from heapq import heappop, heappush

n = int(input())
S = list(map(int, list(input())))
T = list(map(int, list(input())))
op_idx = n
Heap = []
different_num_set = set()
for i in range(n):
    if S[i] != T[i]:
        heappush(Heap, i)
        different_num_set.add(i)

q = int(input())
for _ in range(q):
    c, x, y = input().split()
    x = int(x)
    y = int(y)
    x -= 1

    pre_same = S[x] == T[x]
    if c == 'S':
        S[x] = y
    elif c == 'T':
        T[x] = y
    curr_same = S[x] == T[x]
    if curr_same != pre_same:
        if pre_same:
            heappush(Heap, x)
            different_num_set.add(x)
        else:
            different_num_set.remove(x)
    
    while Heap and Heap[0] not in different_num_set:
        heappop(Heap)
    if len(Heap) == 0:
        print('=')
        continue
    d = Heap[0]
    if S[d] > T[d]:
        print('>')
    elif S[d] < T[d]:
        print('<')
0