結果

問題 No.225 文字列変更(medium)
ユーザー 👑 rin204rin204
提出日時 2022-07-04 13:35:12
言語 PyPy3
(7.3.13)
結果
WA  
実行時間 -
コード長 407 bytes
コンパイル時間 700 ms
コンパイル使用メモリ 86,908 KB
実行使用メモリ 84,248 KB
最終ジャッジ日時 2023-08-20 20:21:47
合計ジャッジ時間 4,068 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 102 ms
82,000 KB
testcase_02 AC 64 ms
71,436 KB
testcase_03 AC 62 ms
71,240 KB
testcase_04 AC 66 ms
71,132 KB
testcase_05 AC 67 ms
71,068 KB
testcase_06 AC 67 ms
71,280 KB
testcase_07 WA -
testcase_08 AC 63 ms
71,472 KB
testcase_09 AC 62 ms
71,436 KB
testcase_10 AC 62 ms
71,072 KB
testcase_11 AC 64 ms
71,260 KB
testcase_12 AC 110 ms
83,908 KB
testcase_13 AC 112 ms
84,212 KB
testcase_14 AC 115 ms
84,236 KB
testcase_15 AC 132 ms
84,020 KB
testcase_16 AC 128 ms
84,248 KB
testcase_17 AC 129 ms
84,160 KB
testcase_18 AC 127 ms
83,912 KB
testcase_19 AC 125 ms
83,956 KB
testcase_20 WA -
testcase_21 AC 125 ms
83,984 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, m = map(int, input().split())
S = input()
T = input()
dp = [[0] * (m + 1) for _ in range(n + 1)]
for i in range(1, n + 1):
    dp[i][0] = i
for j in range(1, m + 1):
    dp[0][j] = i

for i in range(n):
    for j in range(m):
        dp[i + 1][j + 1] = min(dp[i][j], dp[i][j + 1], dp[i + 1][j]) + 1
        if S[i] == T[j]:
            dp[i + 1][j + 1] = min(dp[i + 1][j + 1], dp[i][j])
print(dp[-1][-1])
0