Task
Consider a function , which takes in a string and outputs a string, having the following properties:
- For every string , .
- For every strings and , , where is concatenated with .
We will also construct a set of strings, , in the following manner:
- is in .
- If is in then is also in .
- If and are both in then is also in .
You are given a string and a list, , of strings. Knowing that is in , determine for each string from if it belongs to or not.
You will have to write a function with the following head:
std::string check (std::string (*F)(std::string), std::string B, std::vector<std::string> A)
The function should return a string, where the character in '1' if the string from belongs to and '0' otherwise.
Note that you only have the implement the check function, but you can also implement additional helping functions and / or structures or classes.
Please refer to the sample implementation (sample.cpp).
Input
The check function gets the following three arguments (in this particular order):
- The function.
- The string .
- The array of strings .
All the strings will only contain lowercase English alphabet letters.
For tests worth points: the length of the longest string from .
For tests worth more points: the length of the longest string from .
For tests worth more points: only contains 'a's and only returns strings containing 'a's.
For tests worth more points: , the length of the longest string from .
For every testcase, contains at most strings.
Output
The check function returns a string of length equal to the length of , where the character is or depending on whether or not the string is in .
Notes
Given its special type, this problem doesn't have a formal sample test case with a sample output. Here we present and explain the sample test.
Let's consider = and . Then:
- is in .
- is in .
- is in .
- is in .
- is not in .
- is not in .
- is not in .
- ...