結果

問題 No.2629 A replace B replace C
コンテスト
ユーザー NP
提出日時 2024-02-16 22:48:28
言語 Python3
(3.15.0 + numpy 2.5.4 + scipy 1.18.1 + ACL)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
WA  
実行時間 -
コード長 310 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 304 ms
コンパイル使用メモリ 21,468 KB
実行使用メモリ 15,792 KB
最終ジャッジ日時 2026-09-05 18:13:22
合計ジャッジ時間 13,730 ms
ジャッジサーバーID
(参考情報)
judge5_0 / judge2_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 5
other AC * 45 WA * 16
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

def can_transform(S, T):
    for i in range(len(S)):
        if S[i] > T[i] or (S[i] == 'A' and T[i] == 'C'):
            return "No"
        S = S[:i] + S[i:].replace(S[i], T[i])
    return "Yes" if S == T else "No"

N = int(input().strip())
S = input().strip()
T = input().strip()

print(can_transform(S, T))
0