結果

問題 No.1439 Let's Compare!!!!
ユーザー lloyzlloyz
提出日時 2022-02-15 19:07:17
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 790 ms / 2,000 ms
コード長 911 bytes
コンパイル時間 1,545 ms
コンパイル使用メモリ 86,752 KB
実行使用メモリ 142,704 KB
最終ジャッジ日時 2023-09-11 17:01:42
合計ジャッジ時間 9,067 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,140 KB
testcase_01 AC 73 ms
71,208 KB
testcase_02 AC 75 ms
71,120 KB
testcase_03 AC 75 ms
71,172 KB
testcase_04 AC 75 ms
71,232 KB
testcase_05 AC 73 ms
71,388 KB
testcase_06 AC 75 ms
71,148 KB
testcase_07 AC 151 ms
78,820 KB
testcase_08 AC 170 ms
78,496 KB
testcase_09 AC 134 ms
78,116 KB
testcase_10 AC 790 ms
142,272 KB
testcase_11 AC 728 ms
106,764 KB
testcase_12 AC 674 ms
105,256 KB
testcase_13 AC 778 ms
142,584 KB
testcase_14 AC 773 ms
142,704 KB
testcase_15 AC 690 ms
103,040 KB
testcase_16 AC 666 ms
103,072 KB
testcase_17 AC 713 ms
103,028 KB
testcase_18 AC 583 ms
102,608 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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