[Solution] Long Binary String Codeforces Solution | Codeforces Problem Solution 2022
There is a binary string of length , and initally all of its bits are . You are given a binary string , and perform the following operation some times:
- Select some substring of , and replace it with its XOR with .
Find the lexicographically largest string satisfying these constraints, or report that no such string exists.
Formally, choose an index such that . For all , if , then toggle . That is, if , set . Otherwise if , set .
A binary string is lexicographically larger than a binary string of the same length if in the first position where and differ, the string has a bit and the corresponding bit in is .
The only line of each test contains a single binary string ().
If no string exists as described in the statement, output -1. Otherwise, output the integers and () such that the -th and -th bits of the lexicographically maximal are .
No comments:
Post a Comment