結果

問題 No.225 文字列変更(medium)
ユーザー ayaoniayaoni
提出日時 2020-12-28 09:42:37
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 86 ms / 5,000 ms
コード長 832 bytes
コンパイル時間 152 ms
コンパイル使用メモリ 82,320 KB
実行使用メモリ 83,704 KB
最終ジャッジ日時 2024-04-10 08:41:05
合計ジャッジ時間 2,404 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 63 ms
78,484 KB
testcase_01 AC 74 ms
80,936 KB
testcase_02 AC 35 ms
53,120 KB
testcase_03 AC 35 ms
52,248 KB
testcase_04 AC 36 ms
52,596 KB
testcase_05 AC 38 ms
52,584 KB
testcase_06 AC 35 ms
53,852 KB
testcase_07 AC 38 ms
53,240 KB
testcase_08 AC 38 ms
52,660 KB
testcase_09 AC 35 ms
53,072 KB
testcase_10 AC 35 ms
53,152 KB
testcase_11 AC 35 ms
53,240 KB
testcase_12 AC 86 ms
82,656 KB
testcase_13 AC 82 ms
83,704 KB
testcase_14 AC 84 ms
82,948 KB
testcase_15 AC 79 ms
82,868 KB
testcase_16 AC 83 ms
82,916 KB
testcase_17 AC 81 ms
83,064 KB
testcase_18 AC 84 ms
82,372 KB
testcase_19 AC 81 ms
83,016 KB
testcase_20 AC 81 ms
82,692 KB
testcase_21 AC 82 ms
83,028 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))
def U(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def LS2(): return list(sys.stdin.readline().rstrip())


N,M = MI()
S = ' '+U()
T = ' '+U()

dp = [[10000]*(M+1) for _ in range(N+1)]
dp[0][0] = 0
for i in range(1,N+1):
    dp[i][0] = i
for j in range(1,M+1):
    dp[0][j] = j

for i in range(1,N+1):
    for j in range(1,M+1):
        if S[i] == T[j]:
            dp[i][j] = dp[i-1][j-1]
        else:
            dp[i][j] = 1+min(dp[i-1][j],dp[i][j-1],dp[i-1][j-1])

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