CF1698G.Long Binary String
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
There is a binary string t of length 10100 , and initally all of its bits are 0 . You are given a binary string s , and perform the following operation some times:
- Select some substring of t , and replace it with its XOR with s . †
After several operations, the string t has exactly two bits 1 ; that is, there are exactly two distinct indices p and q such that the p -th and q -th bits of t are 1 , and the rest of the bits are 0 . Find the lexicographically largest ‡ string t satisfying these constraints, or report that no such string exists.
† Formally, choose an index i such that 0≤i≤10100−∣s∣ . For all 1≤j≤∣s∣ , if sj=1 , then toggle ti+j . That is, if ti+j=0 , set ti+j=1 . Otherwise if ti+j=1 , set ti+j=0 .
‡ A binary string a is lexicographically larger than a binary string b of the same length if in the first position where a and b differ, the string a has a bit 1 and the corresponding bit in b is 0 .
输入格式
The only line of each test contains a single binary string s ( 1≤∣s∣≤35 ).
输出格式
If no string t exists as described in the statement, output -1. Otherwise, output the integers p and q ( 1≤p<q≤10100 ) such that the p -th and q -th bits of the lexicographically maximal t are 1 .
输入输出样例
输入#1
1
输出#1
1 2
输入#2
001
输出#2
3 4
输入#3
1111
输出#3
1 5
输入#4
00000
输出#4
-1
输入#5
00000111110000011111000001111101010
输出#5
6 37452687
说明/提示
In the first test, you can perform the following operations. $$$$\texttt{00000}\ldots \to \color{red}{\texttt{1}}\texttt{0000}\ldots \to \texttt{1}\color{red}{\texttt{1}}\texttt{000}\ldots $$
In the second test, you can perform the following operations. $$ \texttt{00000}\ldots \to \color{red}{\texttt{001}}\texttt{00}\ldots \to \texttt{0}\color{red}{\texttt{011}}\texttt{0}\ldots $$
In the third test, you can perform the following operations. $$ \texttt{00000}\ldots \to \color{red}{\texttt{1111}}\texttt{0}\ldots \to \texttt{1}\color{red}{\texttt{0001}}\ldots $$
It can be proven that these strings t are the lexicographically largest ones.
In the fourth test, you can't make a single bit texttt1$$, so it is impossible.