結果
| 問題 |
No.225 文字列変更(medium)
|
| ユーザー |
titia
|
| 提出日時 | 2022-07-17 04:19:27 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 722 bytes |
| コンパイル時間 | 72 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 40,320 KB |
| 最終ジャッジ日時 | 2024-06-29 05:20:29 |
| 合計ジャッジ時間 | 19,996 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 16 WA * 6 |
ソースコード
n,m=map(int,input().split())
S=input()
T=input()
DP=[[1<<30]*m for i in range(n)]
if S[0]==T[0]:
DP[0][0]=0
else:
DP[0][0]=1
for i in range(n):
for j in range(m):
if S[i]==T[j]:
if i-1>=0 and j-1>=0:
DP[i][j]=min(DP[i-1][j-1],DP[i][j])
#if i-1>=0:
# DP[i][j]=min(DP[i-1][j],DP[i][j])
#if j-1>=0:
# DP[i][j]=min(DP[i][j-1],DP[i][j])
else:
if i-1>=0 and j-1>=0:
DP[i][j]=min(DP[i-1][j-1]+1,DP[i][j])
if i-1>=0:
DP[i][j]=min(DP[i-1][j]+1,DP[i][j])
if j-1>=0:
DP[i][j]=min(DP[i][j-1]+1,DP[i][j])
print(DP[n-1][m-1])
titia