結果

問題 No.225 文字列変更(medium)
ユーザー konsin_tokagekonsin_tokage
提出日時 2018-03-28 11:42:42
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 373 bytes
コンパイル時間 190 ms
コンパイル使用メモリ 10,828 KB
実行使用メモリ 42,028 KB
最終ジャッジ日時 2023-09-07 19:20:34
合計ジャッジ時間 13,903 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 16 ms
7,816 KB
testcase_03 AC 16 ms
7,820 KB
testcase_04 AC 16 ms
7,776 KB
testcase_05 WA -
testcase_06 AC 17 ms
7,844 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 16 ms
7,760 KB
testcase_12 AC 1,045 ms
37,840 KB
testcase_13 AC 1,140 ms
42,028 KB
testcase_14 AC 1,106 ms
40,956 KB
testcase_15 AC 1,057 ms
31,596 KB
testcase_16 AC 1,104 ms
39,924 KB
testcase_17 AC 1,046 ms
31,652 KB
testcase_18 AC 1,034 ms
35,076 KB
testcase_19 AC 1,083 ms
39,932 KB
testcase_20 AC 1,015 ms
35,784 KB
testcase_21 AC 1,062 ms
39,320 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, m = map(int, input().split())
s = input()
t = input()
dp = [[0]*(m+1) for _ in range(n+1)]
for i in range(n):
    dp[i][0] = i
for i in range(m):
    dp[0][i] = i
for i in range(1, n+1):
    for j in range(1, m+1):
        dp[i][j] = min(
                int(s[i-1]!=t[j-1]) + dp[i-1][j-1],
                1 + dp[i-1][j],
                1 + dp[i][j-1])
print(dp[n][m])
0