Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Error en tiempo de ejecución (NZEC)
Exited with error status 1 Exception in thread "main" java.lang.NullPointerException at Main.main(Main.java:4) |
0.045 s | 11 KBi |
#2 |
Error en tiempo de ejecución (NZEC)
Exited with error status 1 Exception in thread "main" java.lang.NullPointerException at Main.main(Main.java:4) |
0.047 s | 11 KBi |
#3 |
Error en tiempo de ejecución (NZEC)
Exited with error status 1 Exception in thread "main" java.lang.NullPointerException at Main.main(Main.java:4) |
0.055 s | 11 KBi |
#4 |
Error en tiempo de ejecución (NZEC)
Exited with error status 1 Exception in thread "main" java.lang.NullPointerException at Main.main(Main.java:4) |
0.046 s | 11 KBi |
#5 |
Error en tiempo de ejecución (NZEC)
Exited with error status 1 Exception in thread "main" java.lang.NullPointerException at Main.main(Main.java:4) |
0.045 s | 11 KBi |
#6 |
Error en tiempo de ejecución (NZEC)
Exited with error status 1 Exception in thread "main" java.lang.NullPointerException at Main.main(Main.java:4) |
0.051 s | 11 KBi |
#7 |
Error en tiempo de ejecución (NZEC)
Exited with error status 1 Exception in thread "main" java.lang.NullPointerException at Main.main(Main.java:4) |
0.046 s | 11 KBi |
#8 |
Error en tiempo de ejecución (NZEC)
Exited with error status 1 Exception in thread "main" java.lang.NullPointerException at Main.main(Main.java:4) |
0.044 s | 11 KBi |
#9 |
Error en tiempo de ejecución (NZEC)
Exited with error status 1 Exception in thread "main" java.lang.NullPointerException at Main.main(Main.java:4) |
0.052 s | 11 KBi |
#10 |
Error en tiempo de ejecución (NZEC)
Exited with error status 1 Exception in thread "main" java.lang.NullPointerException at Main.main(Main.java:4) |
0.053 s | 11 KBi |
#11 |
Error en tiempo de ejecución (NZEC)
Exited with error status 1 Exception in thread "main" java.lang.NullPointerException at Main.main(Main.java:4) |
0.066 s | 11 KBi |
#12 |
Error en tiempo de ejecución (NZEC)
Exited with error status 1 Exception in thread "main" java.lang.NullPointerException at Main.main(Main.java:4) |
0.048 s | 11 KBi |
#13 |
Error en tiempo de ejecución (NZEC)
Exited with error status 1 Exception in thread "main" java.lang.NullPointerException at Main.main(Main.java:4) |
0.048 s | 11 KBi |
#14 |
Error en tiempo de ejecución (NZEC)
Exited with error status 1 Exception in thread "main" java.lang.NullPointerException at Main.main(Main.java:4) |
0.046 s | 11 KBi |
#15 |
Error en tiempo de ejecución (NZEC)
Exited with error status 1 Exception in thread "main" java.lang.NullPointerException at Main.main(Main.java:4) |
0.05 s | 11 KBi |
#16 |
Error en tiempo de ejecución (NZEC)
Exited with error status 1 Exception in thread "main" java.lang.NullPointerException at Main.main(Main.java:4) |
0.048 s | 11 KBi |
#17 |
Error en tiempo de ejecución (NZEC)
Exited with error status 1 Exception in thread "main" java.lang.NullPointerException at Main.main(Main.java:4) |
0.05 s | 11 KBi |
#18 |
Error en tiempo de ejecución (NZEC)
Exited with error status 1 Exception in thread "main" java.lang.NullPointerException at Main.main(Main.java:4) |
0.047 s | 11 KBi |
#19 |
Error en tiempo de ejecución (NZEC)
Exited with error status 1 Exception in thread "main" java.lang.NullPointerException at Main.main(Main.java:4) |
0.048 s | 11 KBi |
#20 |
Error en tiempo de ejecución (NZEC)
Exited with error status 1 Exception in thread "main" java.lang.NullPointerException at Main.main(Main.java:4) |
0.051 s | 11 KBi |
#21 |
Error en tiempo de ejecución (NZEC)
Exited with error status 1 Exception in thread "main" java.lang.NullPointerException at Main.main(Main.java:4) |
0.054 s | 11 KBi |
#22 |
Error en tiempo de ejecución (NZEC)
Exited with error status 1 Exception in thread "main" java.lang.NullPointerException at Main.main(Main.java:4) |
0.049 s | 11 KBi |
#23 |
Error en tiempo de ejecución (NZEC)
Exited with error status 1 Exception in thread "main" java.lang.NullPointerException at Main.main(Main.java:4) |
0.048 s | 11 KBi |
#24 |
Error en tiempo de ejecución (NZEC)
Exited with error status 1 Exception in thread "main" java.lang.NullPointerException at Main.main(Main.java:4) |
0.051 s | 11 KBi |
#25 |
Error en tiempo de ejecución (NZEC)
Exited with error status 1 Exception in thread "main" java.lang.NullPointerException at Main.main(Main.java:4) |
0.046 s | 11 KBi |
#26 |
Error en tiempo de ejecución (NZEC)
Exited with error status 1 Exception in thread "main" java.lang.NullPointerException at Main.main(Main.java:4) |
0.049 s | 11 KBi |
#27 |
Error en tiempo de ejecución (NZEC)
Exited with error status 1 Exception in thread "main" java.lang.NullPointerException at Main.main(Main.java:4) |
0.049 s | 11 KBi |
public class Main { public static void main(String[] args) { // Leer las dos strings de la entrada String a = System.console().readLine(); String b = System.console().readLine(); // Calcular la distancia de Levenshtein int resultado = calcularDistanciaLevenshtein(a, b); // Imprimir el resultado System.out.println(resultado); } static int calcularDistanciaLevenshtein(String a, String b) { int m = a.length(); int n = b.length(); // Crear una matriz de tamaño (m+1) x (n+1) e inicializarla int[][] matriz = new int[m + 1][n + 1]; for (int i = 0; i <= m; i++) { matriz[i][0] = i; } for (int j = 0; j <= n; j++) { matriz[0][j] = j; } // Llenar la matriz utilizando el algoritmo de Levenshtein for (int i = 1; i <= m; i++) { for (int j = 1; j <= n; j++) { if (a.charAt(i - 1) == b.charAt(j - 1)) { matriz[i][j] = matriz[i - 1][j - 1]; } else { matriz[i][j] = 1 + Math.min(Math.min(matriz[i - 1][j], matriz[i][j - 1]), matriz[i - 1][j - 1]); } } } // La última celda de la matriz contiene la distancia de Levenshtein return matriz[m][n]; } }