結果

問題 No.225 文字列変更(medium)
ユーザー ckawatakckawatak
提出日時 2019-03-30 17:45:47
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 388 bytes
コンパイル時間 746 ms
コンパイル使用メモリ 82,156 KB
実行使用メモリ 83,360 KB
最終ジャッジ日時 2024-04-27 16:52:18
合計ジャッジ時間 2,911 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 37 ms
52,968 KB
testcase_03 AC 37 ms
52,200 KB
testcase_04 AC 38 ms
52,864 KB
testcase_05 WA -
testcase_06 AC 38 ms
52,496 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 37 ms
52,616 KB
testcase_12 AC 99 ms
82,916 KB
testcase_13 AC 98 ms
83,352 KB
testcase_14 AC 97 ms
83,340 KB
testcase_15 AC 103 ms
82,700 KB
testcase_16 AC 96 ms
82,736 KB
testcase_17 AC 100 ms
83,360 KB
testcase_18 AC 101 ms
82,716 KB
testcase_19 AC 96 ms
82,772 KB
testcase_20 AC 98 ms
82,528 KB
testcase_21 AC 97 ms
82,928 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

dp = []
for _ in range(N+1):
    dp.append([0 for _ in range(M+1)])

for i in range(N):
    dp[i][0] = i
    
for j in range(M):
    dp[0][j] = j

for i in range(N):
    for j in range(M):
        cost = 0 if S[i] == T[j] else 1
        dp[i+1][j+1] = min(dp[i+1][j] + 1, dp[i][j+1] + 1, dp[i][j] + cost)

print(dp[N][M])
0