Submission #61158491
Source Code Expand
Copy
import java.util.Scanner;public class Main {public static void main(String[] args) {Scanner in = new Scanner(System.in);int k = in.nextInt();String S = in.next();String T = in.next();if(check(S,T,k)){System.out.println("Yes");}else {System.out.println("No");}}public static boolean check(String S, String T, int K) {int m = S.length();int n = T.length();if (Math.abs(m - n) > K) return false;
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int k = in.nextInt(); String S = in.next(); String T = in.next(); if(check(S,T,k)){ System.out.println("Yes"); }else { System.out.println("No"); } } public static boolean check(String S, String T, int K) { int m = S.length(); int n = T.length(); if (Math.abs(m - n) > K) return false; int[][] dp = new int[m + 1][n + 1]; for (int i = 0; i <= m; i++) dp[i][0] = i; for (int j = 0; j <= n; j++) dp[0][j] = j; for (int i = 1; i <= m; i++) { for (int j = 1; j <= n; j++) { if (S.charAt(i - 1) == T.charAt(j - 1)) { dp[i][j] = dp[i - 1][j - 1]; } else { dp[i][j] = Math.min(dp[i - 1][j - 1], Math.min(dp[i][j - 1], dp[i - 1][j])) + 1; } } } return dp[m][n] <= K; } }
Submission Info
Submission Time | |
---|---|
Task | F - Operate K |
User | pitch_black |
Language | Java (OpenJDK 17) |
Score | 0 |
Code Size | 1228 Byte |
Status | RE |
Exec Time | 763 ms |
Memory | 988744 KB |
Judge Result
Set Name | Sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 525 | ||||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | sample_01.txt, sample_02.txt, sample_03.txt |
All | hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, sample_01.txt, sample_02.txt, sample_03.txt, small_01.txt, small_02.txt, small_03.txt, small_04.txt, small_05.txt, small_06.txt, test_01.txt, test_02.txt, test_03.txt, test_04.txt, test_05.txt, test_06.txt, test_07.txt, test_08.txt, test_09.txt, test_10.txt, test_11.txt, test_12.txt, test_13.txt, test_14.txt, test_15.txt, test_16.txt, test_17.txt, test_18.txt, test_19.txt, test_20.txt, test_21.txt, test_22.txt, test_23.txt, test_24.txt, test_25.txt, test_26.txt, test_27.txt, test_28.txt, test_29.txt, test_30.txt, test_31.txt, test_32.txt, test_33.txt, test_34.txt, test_35.txt, test_36.txt, test_37.txt, test_38.txt, test_39.txt, test_40.txt, test_41.txt, test_42.txt, test_43.txt, test_44.txt, test_45.txt, test_46.txt, test_47.txt, test_48.txt, test_49.txt, test_50.txt, test_51.txt, test_52.txt, test_53.txt, test_54.txt, test_55.txt, test_56.txt, test_57.txt, test_58.txt, test_59.txt, test_60.txt, test_61.txt, test_62.txt, test_63.txt, test_64.txt, test_65.txt, test_66.txt, test_67.txt, test_68.txt, test_69.txt, test_70.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
hand_01.txt | RE | 747 ms | 987528 KB |
hand_02.txt | RE | 754 ms | 987460 KB |
hand_03.txt | RE | 742 ms | 987668 KB |
hand_04.txt | RE | 752 ms | 987636 KB |
sample_01.txt | AC | 68 ms | 38060 KB |
sample_02.txt | AC | 69 ms | 38108 KB |
sample_03.txt | AC | 70 ms | 37860 KB |
small_01.txt | AC | 70 ms | 38028 KB |
small_02.txt | AC | 69 ms | 37824 KB |
small_03.txt | AC | 68 ms | 38012 KB |
small_04.txt | AC | 68 ms | 37812 KB |
small_05.txt | AC | 70 ms | 38052 KB |
small_06.txt | AC | 69 ms | 37816 KB |
test_01.txt | AC | 69 ms | 37796 KB |
test_02.txt | AC | 70 ms | 37832 KB |
test_03.txt | AC | 70 ms | 37868 KB |
test_04.txt | AC | 70 ms | 37844 KB |
test_05.txt | AC | 71 ms | 38060 KB |
test_06.txt | RE | 754 ms | 987652 KB |
test_07.txt | RE | 739 ms | 987324 KB |
test_08.txt | RE | 743 ms | 987812 KB |
test_09.txt | AC | 153 ms | 43200 KB |
test_10.txt | AC | 150 ms | 43032 KB |
test_11.txt | AC | 141 ms | 42524 KB |
test_12.txt | AC | 137 ms | 42164 KB |
test_13.txt | AC | 123 ms | 40436 KB |
test_14.txt | AC | 130 ms | 40868 KB |
test_15.txt | RE | 755 ms | 987600 KB |
test_16.txt | RE | 747 ms | 987384 KB |
test_17.txt | RE | 747 ms | 987788 KB |
test_18.txt | RE | 749 ms | 987604 KB |
test_19.txt | RE | 744 ms | 987576 KB |
test_20.txt | RE | 751 ms | 987332 KB |
test_21.txt | RE | 746 ms | 987448 KB |
test_22.txt | RE | 747 ms | 987424 KB |
test_23.txt | RE | 748 ms | 987392 KB |
test_24.txt | AC | 156 ms | 43036 KB |
test_25.txt | RE | 747 ms | 987368 KB |
test_26.txt | AC | 154 ms | 43248 KB |
test_27.txt | RE | 749 ms | 987724 KB |
test_28.txt | RE | 745 ms | 987648 KB |
test_29.txt | AC | 160 ms | 43412 KB |
test_30.txt | AC | 154 ms | 43280 KB |
test_31.txt | AC | 143 ms | 42636 KB |
test_32.txt | AC | 139 ms | 42428 KB |
test_33.txt | RE | 739 ms | 987320 KB |
test_34.txt | AC | 142 ms | 42212 KB |
test_35.txt | AC | 157 ms | 42892 KB |
test_36.txt | RE | 749 ms | 987596 KB |
test_37.txt | RE | 742 ms | 987616 KB |
test_38.txt | RE | 746 ms | 987840 KB |
test_39.txt | RE | 744 ms | 987520 KB |
test_40.txt | RE | 750 ms | 987680 KB |
test_41.txt | AC | 154 ms | 43128 KB |
test_42.txt | RE | 758 ms | 987568 KB |
test_43.txt | AC | 154 ms | 43196 KB |
test_44.txt | RE | 749 ms | 987572 KB |
test_45.txt | AC | 148 ms | 43140 KB |
test_46.txt | RE | 753 ms | 987896 KB |
test_47.txt | AC | 148 ms | 43120 KB |
test_48.txt | RE | 742 ms | 988444 KB |
test_49.txt | RE | 751 ms | 988412 KB |
test_50.txt | RE | 749 ms | 988240 KB |
test_51.txt | RE | 747 ms | 988376 KB |
test_52.txt | RE | 751 ms | 988512 KB |
test_53.txt | RE | 753 ms | 988596 KB |
test_54.txt | RE | 747 ms | 988744 KB |
test_55.txt | RE | 763 ms | 988400 KB |
test_56.txt | RE | 750 ms | 988480 KB |
test_57.txt | RE | 748 ms | 988536 KB |
test_58.txt | RE | 754 ms | 988244 KB |
test_59.txt | RE | 747 ms | 988488 KB |
test_60.txt | RE | 749 ms | 988612 KB |
test_61.txt | RE | 752 ms | 988552 KB |
test_62.txt | RE | 751 ms | 988508 KB |
test_63.txt | RE | 747 ms | 988188 KB |
test_64.txt | AC | 69 ms | 38048 KB |
test_65.txt | AC | 69 ms | 38008 KB |
test_66.txt | AC | 72 ms | 37992 KB |
test_67.txt | AC | 70 ms | 37764 KB |
test_68.txt | AC | 70 ms | 37848 KB |
test_69.txt | AC | 70 ms | 37920 KB |
test_70.txt | AC | 69 ms | 38064 KB |