Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.007 s | 3 KBi |
#2 |
Correcto
|
0.023 s | 3 KBi |
#3 |
Incorrecto
|
0.027 s | 3 KBi |
#4 |
Correcto
|
0.038 s | 7 KBi |
#5 |
Correcto
|
0.033 s | 3 KBi |
#6 |
Correcto
|
0.03 s | 3 KBi |
#7 |
Correcto
|
0.027 s | 3 KBi |
#8 |
Correcto
|
0.024 s | 4 KBi |
#9 |
Correcto
|
0.011 s | 3 KBi |
#10 |
Correcto
|
0.008 s | 3 KBi |
#11 |
Correcto
|
0.02 s | 3 KBi |
#12 |
Correcto
|
0.033 s | 3 KBi |
#13 |
Correcto
|
0.025 s | 3 KBi |
#14 |
Correcto
|
0.026 s | 7 KBi |
#15 |
Correcto
|
0.03 s | 3 KBi |
#16 |
Correcto
|
0.027 s | 3 KBi |
#17 |
Correcto
|
0.024 s | 3 KBi |
#18 |
Correcto
|
0.031 s | 3 KBi |
#19 |
Correcto
|
0.026 s | 3 KBi |
#20 |
Correcto
|
0.02 s | 3 KBi |
#21 |
Incorrecto
|
0.161 s | 9 KBi |
#22 |
Correcto
|
1.372 s | 23 KBi |
#23 |
Correcto
|
0.336 s | 32 KBi |
#24 |
Correcto
|
1.219 s | 19 KBi |
#25 |
Incorrecto
|
0.283 s | 22 KBi |
#26 |
Correcto
|
1.04 s | 26 KBi |
#27 |
Correcto
|
0.94 s | 32 KBi |
s = input() t = input() # well bottom up dp has never been my strong # suit, but i think top down translates to this n, m = len(s), len(t) dp = [[0 for _ in range(m + 1)] for _ in range(n + 1)] for j in range(len(t)): dp[len(s)][j] = len(t) - 1 for i in range(len(s)): dp[i][len(t)] = len(s) - 1 dp[len(s)][len(t)] = 0 for i in range(len(s) - 1, -1, -1): for j in range(len(t) - 1, -1, -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[0][0])