結果

問題 No.225 文字列変更(medium)
ユーザー OttyLabOttyLab
提出日時 2021-08-01 22:28:53
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 400 bytes
コンパイル時間 440 ms
コンパイル使用メモリ 87,176 KB
実行使用メモリ 84,816 KB
最終ジャッジ日時 2023-10-14 19:03:52
合計ジャッジ時間 3,976 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 96 ms
79,828 KB
testcase_01 AC 112 ms
82,080 KB
testcase_02 AC 69 ms
71,260 KB
testcase_03 AC 67 ms
71,284 KB
testcase_04 AC 67 ms
71,500 KB
testcase_05 WA -
testcase_06 AC 68 ms
71,380 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 68 ms
71,384 KB
testcase_10 AC 69 ms
71,596 KB
testcase_11 AC 68 ms
71,404 KB
testcase_12 AC 124 ms
84,144 KB
testcase_13 WA -
testcase_14 AC 124 ms
84,664 KB
testcase_15 AC 117 ms
84,044 KB
testcase_16 AC 123 ms
84,316 KB
testcase_17 AC 122 ms
84,116 KB
testcase_18 AC 123 ms
83,620 KB
testcase_19 AC 125 ms
83,876 KB
testcase_20 WA -
testcase_21 AC 122 ms
83,852 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

INF = 10**3
DP = []
for _ in range(N+1):
    DP.append([INF]*(M+1))
DP[0][0] = 0 
for i in range(N):
    for j in range(M):
        if S[i] == T[j]:
            DP[i+1][j+1] = min(DP[i][j], DP[i+1][j] + 1, DP[i][j+1] + 1)
        else:
            DP[i+1][j+1] = min(DP[i+1][j+1], DP[i][j] + 1, DP[i+1][j] + 1, DP[i][j+1] + 1)
print(DP[N][M])
0