結果

問題 No.3261 yiwiy9 → yiwiY9
ユーザー norioc
提出日時 2025-09-06 15:32:48
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 52 ms / 2,000 ms
コード長 458 bytes
コンパイル時間 271 ms
コンパイル使用メモリ 82,044 KB
実行使用メモリ 67,660 KB
最終ジャッジ日時 2025-09-06 15:33:00
合計ジャッジ時間 2,652 ms
ジャッジサーバーID
(参考情報)
judge / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

def replace(s: str) -> str:
    res = []
    t = s
    xs = [('9yiwiy', '9Yiwiy'), ('yiwiy9', 'yiwiY9')]
    p = 0
    while p < len(t):
        for a, b in xs:
            if t.startswith(a, p):
                res.append(b)
                p += len(a)
                break
        else:
            res.append(t[p])
            p += 1

    return ''.join(res)


H, W = map(int, input().split())
for s in [input() for _ in range(H)]:
    print(replace(s))
0