結果

問題 No.225 文字列変更(medium)
ユーザー ksngngksngng
提出日時 2024-02-07 18:38:09
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 105 ms / 5,000 ms
コード長 392 bytes
コンパイル時間 2,240 ms
コンパイル使用メモリ 81,444 KB
実行使用メモリ 82,888 KB
最終ジャッジ日時 2024-02-07 18:38:13
合計ジャッジ時間 3,492 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 64 ms
78,304 KB
testcase_01 AC 75 ms
80,356 KB
testcase_02 AC 31 ms
53,460 KB
testcase_03 AC 30 ms
53,460 KB
testcase_04 AC 32 ms
53,460 KB
testcase_05 AC 31 ms
53,460 KB
testcase_06 AC 32 ms
53,460 KB
testcase_07 AC 32 ms
53,460 KB
testcase_08 AC 34 ms
53,460 KB
testcase_09 AC 33 ms
53,460 KB
testcase_10 AC 35 ms
53,460 KB
testcase_11 AC 33 ms
53,460 KB
testcase_12 AC 90 ms
82,380 KB
testcase_13 AC 87 ms
82,888 KB
testcase_14 AC 87 ms
82,644 KB
testcase_15 AC 87 ms
82,396 KB
testcase_16 AC 88 ms
82,516 KB
testcase_17 AC 105 ms
82,380 KB
testcase_18 AC 87 ms
82,260 KB
testcase_19 AC 88 ms
82,396 KB
testcase_20 AC 85 ms
82,012 KB
testcase_21 AC 85 ms
82,388 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,M=map(int,input().split())
S=input()
T=input()

dp=[[10**18]*(M+1) for _ in range(N+1)]
dp[0][0]=0

for i in range(N+1):
    for j in range(M+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)
        if j>0 and i>0:
            dp[i][j] = min(dp[i][j], dp[i-1][j-1]+(S[i-1]!=T[j-1]))

print(dp[N][M])
0