結果

問題 No.225 文字列変更(medium)
ユーザー nep_pudding3nep_pudding3
提出日時 2019-07-09 18:55:47
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 965 ms / 5,000 ms
コード長 342 bytes
コンパイル時間 120 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 42,624 KB
最終ジャッジ日時 2024-04-20 16:32:46
合計ジャッジ時間 11,526 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 397 ms
22,016 KB
testcase_01 AC 670 ms
32,256 KB
testcase_02 AC 30 ms
10,880 KB
testcase_03 AC 32 ms
10,880 KB
testcase_04 AC 32 ms
10,752 KB
testcase_05 AC 31 ms
10,752 KB
testcase_06 AC 32 ms
10,752 KB
testcase_07 AC 32 ms
10,624 KB
testcase_08 AC 31 ms
10,752 KB
testcase_09 AC 32 ms
10,752 KB
testcase_10 AC 31 ms
10,752 KB
testcase_11 AC 31 ms
10,880 KB
testcase_12 AC 855 ms
35,712 KB
testcase_13 AC 965 ms
42,624 KB
testcase_14 AC 934 ms
40,576 KB
testcase_15 AC 666 ms
25,856 KB
testcase_16 AC 909 ms
40,064 KB
testcase_17 AC 664 ms
25,856 KB
testcase_18 AC 740 ms
30,976 KB
testcase_19 AC 917 ms
40,320 KB
testcase_20 AC 779 ms
33,024 KB
testcase_21 AC 887 ms
38,912 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,m = map(int,input().split())
S = input()
T = input()
DP = [[0]*(m+1) for i in range(n+1)]
DP[0] = [i for i in range(m+1)]
for i in range(n):
    DP[i+1][0] = i+1
    for j in range(m):
        if S[i] == T[j]:
            DP[i+1][j+1] = DP[i][j]
        else:
            DP[i+1][j+1] = min(DP[i][j],DP[i+1][j],DP[i][j+1])+1
print(DP[n][m])
0