結果

問題 No.225 文字列変更(medium)
ユーザー 👑 H20H20
提出日時 2021-06-29 13:50:08
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 431 bytes
コンパイル時間 245 ms
コンパイル使用メモリ 87,276 KB
実行使用メモリ 84,864 KB
最終ジャッジ日時 2023-09-08 00:14:36
合計ジャッジ時間 3,743 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 114 ms
82,244 KB
testcase_02 AC 69 ms
71,532 KB
testcase_03 AC 69 ms
71,468 KB
testcase_04 AC 69 ms
71,104 KB
testcase_05 AC 66 ms
71,432 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 67 ms
71,652 KB
testcase_10 AC 69 ms
71,460 KB
testcase_11 WA -
testcase_12 AC 132 ms
84,164 KB
testcase_13 AC 131 ms
84,864 KB
testcase_14 AC 127 ms
84,748 KB
testcase_15 AC 132 ms
84,080 KB
testcase_16 AC 130 ms
84,512 KB
testcase_17 AC 131 ms
84,344 KB
testcase_18 AC 131 ms
84,372 KB
testcase_19 AC 130 ms
84,504 KB
testcase_20 WA -
testcase_21 AC 130 ms
84,544 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,M = map(int,input().split())
S = input()
T = input()
DP = [[10**5]*(M+1) for _ in range(N+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+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+1][j],DP[i][j]+1)
        DP[i][j+1]=min(DP[i][j+1],DP[i][j]+1)

print(min(DP[N][M],DP[N-1][M]+1,DP[N][M-1]+1))
0