結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 710 ms
30,324 KB
testcase_02 WA -
testcase_03 AC 16 ms
7,852 KB
testcase_04 AC 16 ms
7,976 KB
testcase_05 AC 16 ms
7,844 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 17 ms
7,840 KB
testcase_10 AC 17 ms
7,768 KB
testcase_11 WA -
testcase_12 AC 991 ms
37,896 KB
testcase_13 AC 1,071 ms
42,128 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 1,037 ms
39,868 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 1,021 ms
39,920 KB
testcase_20 WA -
testcase_21 AC 1,044 ms
39,336 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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