[Solution] Linguistics Codeforces Solution | Codeforces Problem Solution 2022
Alina has discovered a weird language, which contains only words: , , , . It also turned out that there are no spaces in this language: a sentence is written by just concatenating its words into a single string.
Alina has found one such sentence and she is curious: is it possible that it consists of precisely words , words , words , and words ?
In other words, determine, if it's possible to concatenate these words in some order so that the
resulting string is . Each of the words must be used exactly once in the concatenation, but you can choose the order in which they are concatenated.
The first line of the input contains a single integer () — the number of test cases. The description of the test cases follows.
The first line of each test case contains four integers , , , () — the number of times that words , , , respectively must be used in the sentence.
The second line contains the string ( consists only of the characters and , , ) — the sentence. Notice that the condition (here denotes the length of the string ) is equivalent to the fact that is as long as the concatenation of the words.
The sum of the lengths of over all test cases doesn't exceed .
For each test case output if it is possible that the sentence consists of precisely words , words , words , and words , and otherwise. You can output each letter in any case.
No comments:
Post a Comment