[Solution] Hard Cut Codeforces Solution | Codeforces Problem Solution 2022
H. Hard Cut
time limit per test
2 secondsmemory limit per test
256 megabytesinput
standard inputoutput
standard outputYou are given a binary string . You have to cut it into any number of non-intersecting substrings, so that the sum of binary integers denoted by these substrings is a power of 2. Each element of should be in exactly one substring.
Input
Each test contains multiple test cases. The first line contains the number of test cases (). Description of the test cases follows.
Solution Click Below:- CLICK HERE
Each test case contains a binary string ().
It is guaranteed that the sum of over all test cases does not exceed .
Output
For each test case output the answer to the problem as follows:
- If the answer does not exist, output .
- If the answer exists, firstly output an integer — the number of substrings in the answer. After that output non-intersecting substrings, for -th substring output two integers () — the description of -th substring.
If there are multiple valid solutions, you can output any of them.
No comments:
Post a Comment