結果

問題 No.225 文字列変更(medium)
ユーザー rpy3cpprpy3cpp
提出日時 2015-06-13 16:23:13
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
(最新)
AC  
(最初)
実行時間 -
コード長 265 bytes
コンパイル時間 228 ms
コンパイル使用メモリ 10,920 KB
実行使用メモリ 37,520 KB
最終ジャッジ日時 2023-09-21 00:57:13
合計ジャッジ時間 8,356 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 AC 16 ms
7,976 KB
testcase_03 AC 16 ms
7,812 KB
testcase_04 AC 16 ms
7,892 KB
testcase_05 AC 15 ms
7,892 KB
testcase_06 AC 16 ms
7,812 KB
testcase_07 AC 16 ms
7,864 KB
testcase_08 AC 16 ms
7,952 KB
testcase_09 AC 17 ms
7,812 KB
testcase_10 AC 16 ms
7,956 KB
testcase_11 AC 16 ms
7,860 KB
testcase_12 AC 698 ms
29,124 KB
testcase_13 AC 923 ms
37,520 KB
testcase_14 AC 833 ms
35,144 KB
testcase_15 AC 323 ms
16,568 KB
testcase_16 AC 861 ms
35,336 KB
testcase_17 AC 333 ms
16,836 KB
testcase_18 AC 515 ms
22,564 KB
testcase_19 AC 842 ms
35,616 KB
testcase_20 AC 595 ms
25,680 KB
testcase_21 AC 784 ms
33,244 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,m=map(int,input().split())
S=input()
T=input()
d=[[i]+[-1]*m for i in range(n+1)]
d[0]=list(range(m+1))
def f(a,b):
 global d
 if d[a][b]>=0:return d[a][b]
 t=f(a-1,b-1) if S[a-1]==T[b-1] else 1+min(f(a-1,b-1),f(a,b-1),f(a-1,b))
 d[a][b]=t
 return t
print(f(n,m))
0