結果
| 問題 |
No.225 文字列変更(medium)
|
| コンテスト | |
| ユーザー |
ffuture
|
| 提出日時 | 2020-09-26 22:09:38 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 847 ms / 5,000 ms |
| コード長 | 691 bytes |
| コンパイル時間 | 78 ms |
| コンパイル使用メモリ | 12,800 KB |
| 実行使用メモリ | 42,496 KB |
| 最終ジャッジ日時 | 2024-06-29 22:14:47 |
| 合計ジャッジ時間 | 9,735 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 22 |
ソースコード
def min(a,b,c):
if a>b:
if b>c:
return c
else:
return b
else:
if a>c:
return c
else:
return a
n,m = map(int,input().split())
S=input()
T=input()
inf=float('inf')
a=[]
for i in range(0,n+1):
a.append([inf]*(m+1))
a[0][0]=0
for i in range(0,n+1):
for j in range(0,m+1):
if j==0 and i==0:
continue
elif j==0:
a[i][j]=a[i-1][j]+1
elif i==0:
a[i][j]=a[i][j-1]+1
else:
if S[i-1]==T[j-1]:
a[i][j]=a[i-1][j-1]
else:
a[i][j]=min(a[i][j-1],a[i-1][j],a[i-1][j-1])+1
print(a[n][m])
ffuture