結果

問題 No.225 文字列変更(medium)
ユーザー しらっ亭しらっ亭
提出日時 2015-06-17 21:55:20
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 487 bytes
コンパイル時間 691 ms
コンパイル使用メモリ 10,736 KB
実行使用メモリ 157,376 KB
最終ジャッジ日時 2023-09-21 09:22:26
合計ジャッジ時間 15,681 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 16 ms
7,752 KB
testcase_03 AC 15 ms
7,832 KB
testcase_04 AC 16 ms
7,804 KB
testcase_05 AC 15 ms
7,920 KB
testcase_06 WA -
testcase_07 AC 16 ms
7,800 KB
testcase_08 AC 16 ms
7,816 KB
testcase_09 AC 15 ms
7,756 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 1,297 ms
157,376 KB
testcase_14 WA -
testcase_15 AC 1,198 ms
141,280 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 1,148 ms
145,448 KB
testcase_21 AC 1,204 ms
149,060 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def solve(s1, s2):
    d = {}

    for i in range(len(s1)):
        d[i, 0] = i
    for j in range(len(s2)):
        d[0, j] = j

    for i in range(1, len(s1)):
        for j in range(1, len(s2)):
            n = 0 if s1[i] == s2[j] else 1
            d[i, j] = min(d[i - 1, j] + 1, d[i, j - 1] + 1, d[i - 1, j - 1] + n)

    return d[len(s1) - 1, len(s2) - 1]


def main():
    input()
    s1 = input()
    s2 = input()
    print(solve(s1, s2))


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