結果
問題 | No.225 文字列変更(medium) |
ユーザー |
![]() |
提出日時 | 2020-01-28 14:57:15 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 656 ms / 5,000 ms |
コード長 | 729 bytes |
コンパイル時間 | 159 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 44,544 KB |
最終ジャッジ日時 | 2024-09-15 13:38:00 |
合計ジャッジ時間 | 8,417 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 22 |
ソースコード
import sys sys.setrecursionlimit(10 ** 6) int1 = lambda x: int(x) - 1 p2D = lambda x: print(*x, sep="\n") def II(): return int(sys.stdin.readline()) def MI(): return map(int, sys.stdin.readline().split()) def LI(): return list(map(int, sys.stdin.readline().split())) def LLI(rows_number): return [LI() for _ in range(rows_number)] def SI(): return sys.stdin.readline()[:-1] def main(): # 編集距離ってやつ n,m=MI() s=SI() t=SI() dp=[[0]*(m+1) for _ in range(n+1)] for j in range(m+1):dp[0][j]=j for i in range(n+1):dp[i][0]=i for i,c0 in enumerate(s): for j,c1 in enumerate(t): dp[i+1][j+1]=min(dp[i][j+1]+1,dp[i+1][j]+1,dp[i][j]+(c0!=c1)) print(dp[n][m]) main()