結果

問題 No.1439 Let's Compare!!!!
ユーザー ThetaTheta
提出日時 2022-10-14 17:22:11
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 1,698 bytes
コンパイル時間 107 ms
コンパイル使用メモリ 10,848 KB
実行使用メモリ 19,264 KB
最終ジャッジ日時 2023-09-08 19:45:52
合計ジャッジ時間 4,339 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
12,768 KB
testcase_01 AC 15 ms
8,320 KB
testcase_02 AC 16 ms
8,204 KB
testcase_03 AC 16 ms
8,212 KB
testcase_04 AC 16 ms
8,252 KB
testcase_05 AC 15 ms
8,216 KB
testcase_06 AC 15 ms
8,176 KB
testcase_07 AC 62 ms
8,512 KB
testcase_08 AC 85 ms
8,412 KB
testcase_09 AC 32 ms
8,216 KB
testcase_10 TLE -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

def judge_which_larger(
        compare: list[str], init_digit: int = 1) -> tuple[str, int]:
    for digit, mark in enumerate(compare[init_digit-1:], init_digit):
        if mark == "=":
            continue
        return mark, digit
    return "=", digit


def main():
    _ = input()
    S = list(map(int, str(input())))
    T = list(map(int, str(input())))
    S_T_compare = []
    for s_num, t_num in zip(S, T):
        if s_num > t_num:
            S_T_compare.append(">")
        elif s_num == t_num:
            S_T_compare.append("=")
        else:
            S_T_compare.append("<")

    current_status, diff_digit = judge_which_larger(S_T_compare)

    for _ in range(int(input())):
        which_num, digit, number = input().split()
        digit = int(digit)
        number = int(number)
        if which_num == "S":
            S[digit-1] = number
        elif which_num == "T":
            T[digit-1] = number
        else:
            raise ValueError

        if S[digit-1] > T[digit-1]:
            S_T_compare[digit-1] = ">"
        elif S[digit-1] == T[digit-1]:
            S_T_compare[digit-1] = "="
        else:
            S_T_compare[digit-1] = "<"

        if diff_digit < digit:
            print(current_status)
        elif diff_digit > digit:
            if S_T_compare[digit-1] == "=":
                print(current_status)
            else:
                print(S_T_compare[digit-1])
                current_status = S_T_compare[digit-1]
                diff_digit = digit
        else:
            current_status, diff_digit = judge_which_larger(
                S_T_compare, diff_digit)
            print(current_status)


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