FourSubstrings
TCO07 Round 4 · 2007-03-07 · by Mike Mirzayanov
Problem Statement
You are given a
foursubstrings - text
our - a
s - b
ring - c
sub - d
++++++ ++++ - covered letters
The letters marked by '+' are covered.
Return a
Constraints
- text will contain between 1 and 50 elements, inclusive.
- Each element of text will contain between 1 and 50 characters, inclusive.
- text will contain only lowercase letters ('a'-'z').
- a, b, c and d will each contain between 1 and 50 characters, inclusive.
- a, b, c and d will contain only lowercase letters ('a'-'z').
- a, b, c and d will each be a substring of the concatenation of text.
{"abacaba"}
"ab"
"ba"
"a"
"c"
Returns: {4, 6 }
The minimal number of covered characters corresponds to "ABACaba", and the maximal corresponds to "ABACaBA" (the covered characters are shown in uppercase).
{"hello"}
"he"
"l"
"l"
"o"
Returns: {4, 5 }
Occurrences of substrings may overlap.
{"ababababa", "baba"}
"ababababa"
"ababababa"
"ababababa"
"ababababa"
Returns: {9, 13 }
{"foursubstrings"}
"our"
"s"
"ring"
"sub"
Returns: {10, 11 }
{"aa"}
"a"
"a"
"aa"
"a"
Returns: {2, 2 }
Submissions are judged against all 81 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class FourSubstrings with a public method vector<int> getCoverageCount(vector<string> text, string a, string b, string c, string d) · 81 test cases · 2 s / 256 MB per case