Combinatorics Homework Solution Codeforces Educational Round 144
You are given four integer values, , and .
Check if there exists a string that contains:
- A‘; letters ‘
- B‘; letters ‘
- C‘; letters ‘
- no other letters;
- pairs of adjacent equal letters ( such positions that the -th letter is equal to the -th one).
The first line contains a single integer( ) — the number of testcases.
Each of the nextlines contains the description of the testcase — four integers , , and ( ; ).
For each testcase print “YES” if there exists a string that satisfies all the requirements. Print “NO” if there are no such strings.
You may print every letter in any case you want (so, for example, the strings yEs, yes, Yes and YES will all be recognized as positive answer).
3 2 2 1 0 1 1 1 1 1 2 3 2
YES NO YES
In the first testcase strings “ABCAB” or “BCABA” satisfy the requirements. There exist other possible strings.
In the second testcase there’s no way to put adjacent equal letters if there’s no letter that appears at least twice.
In the third testcase string “CABBCC” satisfies the requirements. There exist other possible strings.