git reimport

This commit is contained in:
2019-03-15 13:47:54 +04:00
commit 3b461f73de
489 changed files with 1631603 additions and 0 deletions

View File

@@ -0,0 +1,58 @@
23 I - Composing Of String
6 SINGLE
8 STANDARD
-1
8 STANDARD
-1
4
0
13 3
a
aa
a
aaa
2 2
1
1
21 4
ab
aab
aa
bb
baaab
2 3
1
2
18 2
aaa
bbb
aaacbbb
3 -1
1
3
10 2
ax
xb
ab
1 2
1
11 src/chelper
8 -Xmx256M
4 Main
13 chelper.TaskI
39 net.egork.chelper.checkers.TokenChecker
0
0
10 2017.04.05
31 VK Cup 2017 - Wild Card Round 1
1
14 io.InputReader
15 io.OutputWriter
0
0

View File

@@ -0,0 +1,61 @@
package chelper;
import java.util.Arrays;
import io.InputReader;
import io.OutputWriter;
public class TaskI {
public static final int MAGIC_KEK = 1000000;
public void solve(int testNumber, InputReader in, OutputWriter out) {
int n = in.nextInt();
String[] strings = new String[n];
for (int i = 0; i < n; i++) {
strings[i] = in.nextString();
}
String e = in.nextString();
int m = e.length();
int[] dp = new int[m + 1];
Arrays.fill(dp, MAGIC_KEK);
dp[0] = 0;
for (int i = 0; i < n; i++) {
for (int j = 0; j < strings[i].length(); j++) {
int c = 0;
for (int k = 0; j + k < strings[i].length() && c < e.length(); k++) {
if (strings[i].charAt(j + k) == e.charAt(c)) {
c++;
dp[c] = Math.max(dp[c], 1);
}
}
}
}
for (int i = 0; i < m; i++) {
for (int j = 0; j < n; j++) {
int c = 0;
for (int k = 0; i + c < e.length() && k < strings[j].length(); k++) {
if (strings[j].charAt(k) == e.charAt(i + c)) {
c++;
dp[i + c] = Math.min(dp[i + c], dp[i] + 1);
}
}
}
}
if (dp[m] >= MAGIC_KEK) {
out.println(-1);
} else {
out.println(dp[m]);
}
}
}