All submissions for this problem are available.
Give a string s of length l, and a set S of n sample string(s). We do reduce the string s using the set S by this way:
- Wherever Si appears as a consecutive substring of the string s, you can delete (or not) it.
- After each deletion, you will get a new string s by joining the part to the left and to the right of the deleted substring.
By that way, try to reduce the given string s to get a new string of minimum length. You can do delete for unlimited times.
- The first line contains the string s.
- The second line contains the integer n.
- Within the last n lines, the i-th line contains the string Si.
Output on a single line an integer which is the minimum length found.
aaabccd 3 abc ac aaa
|Tags||anhdq, hard, oct10|
|Time Limit:||0.3 - 0.345555 sec|
|Source Limit:||50000 Bytes|
|Languages:||ADA, ASM, BASH, BF, C, C99 strict, CAML, CLOJ, CLPS, COB, CPP 4.3.2, CPP 6.3, CPP14, CS2, D, ERL, FORT, FS, GO, HASK, ICK, ICON, JAVA, JS, kotlin, LISP clisp, LISP sbcl, LUA, NEM, NICE, NODEJS, PAS fpc, PAS gpc, PERL, PERL6, PHP, PIKE, PRLG, PYPY, PYTH, PYTH 3.5, RUBY, rust, SCALA, SCM chicken, SCM guile, SCM qobi, ST, swift, TEXT, WSPC|
Fetching successful submissions
If you are still having problems, see a sample solution here.