結果

問題 No.225 文字列変更(medium)
ユーザー roarisroaris
提出日時 2020-01-18 18:58:12
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 450 bytes
コンパイル時間 320 ms
コンパイル使用メモリ 87,200 KB
実行使用メモリ 84,784 KB
最終ジャッジ日時 2023-09-10 09:18:47
合計ジャッジ時間 3,704 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 95 ms
79,924 KB
testcase_01 AC 104 ms
82,464 KB
testcase_02 AC 70 ms
71,248 KB
testcase_03 AC 74 ms
71,448 KB
testcase_04 AC 70 ms
71,308 KB
testcase_05 WA -
testcase_06 AC 71 ms
71,308 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 72 ms
71,308 KB
testcase_10 AC 72 ms
71,308 KB
testcase_11 AC 70 ms
71,480 KB
testcase_12 AC 117 ms
83,712 KB
testcase_13 WA -
testcase_14 AC 115 ms
84,404 KB
testcase_15 AC 119 ms
84,088 KB
testcase_16 AC 113 ms
84,116 KB
testcase_17 AC 118 ms
84,224 KB
testcase_18 AC 117 ms
83,804 KB
testcase_19 AC 114 ms
84,084 KB
testcase_20 WA -
testcase_21 AC 113 ms
84,072 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, m = map(int, input().split())
S = input()
T = input()
dp = [[0]*m for _ in range(n)]
dp[0][0] = 1 if S[0]!=T[0] else 0

for i in range(n):
    for j in range(m):
        if i==0 and j==0:
            continue
        elif i==0:
            dp[i][j] = dp[i][j-1]+1
        elif j==0:
            dp[i][j] = dp[i-1][j]+1
        else:
            dp[i][j] = min(dp[i][j-1]+1, dp[i-1][j]+1, dp[i-1][j-1]+(1 if S[i]!=T[j] else 0))

print(dp[n-1][m-1])
0