Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.006 s | 2 KBi |
#2 |
Correcto
|
0.005 s | 1 KBi |
#3 |
Correcto
|
0.005 s | 1 KBi |
#4 |
Correcto
|
0.004 s | 1 KBi |
#5 |
Correcto
|
0.007 s | 1 KBi |
#6 |
Correcto
|
0.005 s | 1 KBi |
#7 |
Correcto
|
0.007 s | 1 KBi |
#8 |
Correcto
|
0.005 s | 1 KBi |
#9 |
Correcto
|
0.006 s | 1 KBi |
#10 |
Correcto
|
0.007 s | 1 KBi |
#11 |
Correcto
|
0.005 s | 1 KBi |
#12 |
Correcto
|
0.005 s | 1 KBi |
#13 |
Correcto
|
0.004 s | 1 KBi |
#14 |
Correcto
|
0.004 s | 1 KBi |
#15 |
Correcto
|
0.006 s | 1 KBi |
#16 |
Correcto
|
0.005 s | 1 KBi |
#17 |
Correcto
|
0.004 s | 1 KBi |
#18 |
Correcto
|
0.005 s | 1 KBi |
#19 |
Correcto
|
0.005 s | 1 KBi |
#20 |
Correcto
|
0.005 s | 1 KBi |
#21 |
Correcto
|
0.046 s | 8 KBi |
#22 |
Correcto
|
0.044 s | 8 KBi |
#23 |
Correcto
|
0.037 s | 8 KBi |
#24 |
Correcto
|
0.041 s | 7 KBi |
#25 |
Correcto
|
0.047 s | 7 KBi |
#26 |
Correcto
|
0.048 s | 7 KBi |
#27 |
Correcto
|
0.039 s | 7 KBi |
// Made by Daniel Diaz (@Danidiaztech) #include <bits/stdc++.h> using namespace std; #define endl '\n' #define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0); #define forn(i, n) for (int i = 0; i < n; i++) // for in range in python #define FOR(i, a, b) for (int i = a; i < b; i++) // for in range in python #define int long long int #define double long double #define pb push_back #define ff first #define ss second #define mk make_pair typedef pair<int, int> pii; const int MAX = 1e6; const int MIN = -MAX; const int INF = LLONG_MAX; const int MINF = LLONG_MIN; const int MOD = 1e9 + 7; int32_t main() { fastInp; #if LOCAL freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif string x, y; cin >> x >> y; int n = x.size(); int m = y.size(); int dp[n + 1][m + 1]; // Borders for (int j = 0; j <= n ;j++){ dp[j][0] = j; } for (int i = 0; i <= m; i++){ dp[0][i]= i; } for (int i =1; i <= n; i++){ for (int j = 1; j <= m; j++){ dp[i][j] = min({ dp[i -1][j] + 1, dp[i][j - 1] + 1, dp[i -1][j - 1] + (x[i - 1] != y[j - 1]) }); } } // Start calculating dp cout << dp[n][m] << endl; return 0; }