GUPTA MECHANICAL

IN THIS WEBSITE I CAN TELL ALL ABOUT TECH. TIPS AND TRICKS APP REVIEWS AND UNBOXINGS ALSO TECH. NEWS .............

Thursday, 19 May 2022

[Solution] Hard Cut Codeforces Solution | Codeforces Problem Solution 2022

H. Hard Cut
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

You are given a binary string s. 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 s should be in exactly one substring.

Input

Each test contains multiple test cases. The first line contains the number of test cases t (1t105). Description of the test cases follows.

Solution Click Below:-  CLICK HERE

Each test case contains a binary string s (1|s|106).

It is guaranteed that the sum of |s| over all test cases does not exceed 106.

Output

For each test case output the answer to the problem as follows:

  • If the answer does not exist, output 1.
  • If the answer exists, firstly output an integer k — the number of substrings in the answer. After that output k non-intersecting substrings, for i-th substring output two integers li,ri (1li,ri|s|) — the description of i-th substring.

If there are multiple valid solutions, you can output any of them.

No comments:

Post a Comment