[Solution] Make Length 1 CodeChef Solution
Problem
You are given a binary string of length .
You can perform the following operation on :
- Select an index such that .
- Set to and remove from the string.
Note that after each operation, the length of decreases by .
Is it possible to reduce to a single character by performing the mentioned operation exactly times?
Input Format
- The first line of input contains a single integer denoting the number of test cases. The description of test cases follows.
- Each test case consists of two lines of input.
- The first line of each test case contains a single integer , the length of .
- The second line contains a binary string of length .
Output Format
For each test case, print the answer on a new line: YES
if it is possible to perform the operation times, and NO
otherwise.
Each character of the output may be printed in either uppercase or lowercase, i.e, YES
, yes
, yEs
and yES
will all be treated as identical.
Explanation:
Test case : Perform the operation choosing . This sets and deletes from the string, after which is now a single character.
Test case : It is not possible to perform any operation.
Test case : One sequence of operations is as follows:
- Perform the operation on . Now, .
- Perform the operation on . Now, .
- Perform the operation on . Now, and we are done.
Test case : It is not possible to perform any operation.
No comments:
Post a Comment