結果

問題 No.225 文字列変更(medium)
ユーザー convexineqconvexineq
提出日時 2020-12-20 00:50:15
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 101 ms / 5,000 ms
コード長 375 bytes
コンパイル時間 1,438 ms
コンパイル使用メモリ 80,700 KB
実行使用メモリ 82,964 KB
最終ジャッジ日時 2023-10-21 10:00:06
合計ジャッジ時間 2,924 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
78,284 KB
testcase_01 AC 87 ms
80,444 KB
testcase_02 AC 35 ms
53,476 KB
testcase_03 AC 35 ms
53,476 KB
testcase_04 AC 35 ms
53,476 KB
testcase_05 AC 36 ms
53,476 KB
testcase_06 AC 38 ms
53,476 KB
testcase_07 AC 37 ms
53,476 KB
testcase_08 AC 38 ms
53,476 KB
testcase_09 AC 38 ms
53,476 KB
testcase_10 AC 37 ms
53,476 KB
testcase_11 AC 36 ms
53,476 KB
testcase_12 AC 99 ms
82,368 KB
testcase_13 AC 100 ms
82,964 KB
testcase_14 AC 97 ms
82,740 KB
testcase_15 AC 100 ms
82,428 KB
testcase_16 AC 96 ms
82,608 KB
testcase_17 AC 99 ms
82,464 KB
testcase_18 AC 101 ms
82,240 KB
testcase_19 AC 97 ms
82,492 KB
testcase_20 AC 97 ms
82,100 KB
testcase_21 AC 95 ms
82,436 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,m,s,t = open(0).read().split()
n,m = int(n), int(m)
INF = 1<<30
dp = [[INF]*(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: dp[i][j] = min(dp[i][j], dp[i-1][j]+1)
        if j: dp[i][j] = min(dp[i][j], dp[i][j-1]+1)
        if i and j: dp[i][j] = min(dp[i][j], dp[i-1][j-1] + (0 if s[i-1]==t[j-1] else 1))
print(dp[n][m])
0