結果

問題 No.225 文字列変更(medium)
ユーザー AEnAEn
提出日時 2023-06-04 22:36:56
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 129 ms / 5,000 ms
コード長 522 bytes
コンパイル時間 287 ms
コンパイル使用メモリ 87,184 KB
実行使用メモリ 83,892 KB
最終ジャッジ日時 2023-08-28 08:33:02
合計ジャッジ時間 3,913 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 100 ms
79,672 KB
testcase_01 AC 113 ms
81,808 KB
testcase_02 AC 70 ms
71,052 KB
testcase_03 AC 70 ms
71,152 KB
testcase_04 AC 70 ms
71,104 KB
testcase_05 AC 69 ms
71,152 KB
testcase_06 AC 71 ms
70,688 KB
testcase_07 AC 68 ms
70,952 KB
testcase_08 AC 69 ms
70,904 KB
testcase_09 AC 68 ms
71,192 KB
testcase_10 AC 70 ms
70,680 KB
testcase_11 AC 68 ms
71,104 KB
testcase_12 AC 129 ms
83,708 KB
testcase_13 AC 128 ms
83,892 KB
testcase_14 AC 129 ms
83,788 KB
testcase_15 AC 127 ms
83,616 KB
testcase_16 AC 128 ms
83,820 KB
testcase_17 AC 128 ms
83,736 KB
testcase_18 AC 126 ms
83,736 KB
testcase_19 AC 126 ms
83,660 KB
testcase_20 AC 126 ms
83,340 KB
testcase_21 AC 128 ms
83,528 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

_ = input()
S = input()
T = input()
INF = 10**7

dp = [[INF]*(len(T)+1) for _ in range(len(S)+1)]
dp[0][0] = 0

for i in range(len(S)+1):
    for j in range(len(T)+1):
        if i > 0 and j > 0:
            if S[i-1] == T[j-1]:
                dp[i][j] = min(dp[i][j], dp[i-1][j-1])
            else:
                dp[i][j] = min(dp[i][j], dp[i-1][j-1]+1)
        if i > 0:
            dp[i][j] = min(dp[i][j], dp[i-1][j]+1)
        if j > 0:
            dp[i][j] = min(dp[i][j], dp[i][j-1]+1)
print(dp[len(S)][len(T)])
0