結果
問題 | No.225 文字列変更(medium) |
ユーザー |
|
提出日時 | 2021-08-01 22:59:25 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 120 ms / 5,000 ms |
コード長 | 502 bytes |
コンパイル時間 | 361 ms |
コンパイル使用メモリ | 82,404 KB |
実行使用メモリ | 83,876 KB |
最終ジャッジ日時 | 2024-09-16 13:04:19 |
合計ジャッジ時間 | 3,232 ms |
ジャッジサーバーID (参考情報) |
judge6 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 22 |
ソースコード
N, M = map(int, input().split()) S = input() T = input() INF = 10**10 DP = [] for _ in range(N+2): DP.append([INF]*(M+2)) DP[0][0] = 0 for i in range(N+1): for j in range(M+1): if i < N and j < M: if S[i] == T[j]: DP[i+1][j+1] = min(DP[i+1][j+1], DP[i][j]) else: DP[i+1][j+1] = min(DP[i+1][j+1], DP[i][j] + 1) DP[i+1][j] = min(DP[i][j] + 1, DP[i+1][j]) DP[i][j+1] = min(DP[i][j] + 1, DP[i][j+1]) print(DP[N][M])