Codeforces Round 803 (Div. 2)
G
Long Binary String
Codeforces
2900
原题
← F→
翻译中…

There is a binary string $t$ of length $10^{100}$, and initally all of its bits are $\texttt{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$.$^\dagger$
翻译中…

After several operations, the string $t$ has exactly two bits $\texttt{1}$; that is, there are exactly two distinct indices $p$ and $q$ such that the $p$-th and $q$-th bits of $t$ are $\texttt{1}$, and the rest of the bits are $\texttt{0}$.

翻译中…

Find the lexicographically largest$^\ddagger$ string $t$ satisfying these constraints, or report that no such string exists.

翻译中…

$^\dagger$ Formally, choose an index $i$ such that $0 \leq i \leq 10^{100}-|s|$. For all $1 \leq j \leq |s|$, if $s_j = \texttt{1}$, then toggle $t_{i+j}$. That is, if $t_{i+j}=\texttt{0}$, set $t_{i+j}=\texttt{1}$. Otherwise if $t_{i+j}=\texttt{1}$, set $t_{i+j}=\texttt{0}$.

翻译中…

$^\ddagger$ 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 $\texttt{1}$ and the corresponding bit in $b$ is $\texttt{0}$.

翻译中…

Input

翻译中…

The only line of each test contains a single binary string $s$ ($1 \leq |s| \leq 35$).

翻译中…

Output

翻译中…

If no string $t$ exists as described in the statement, output -1. Otherwise, output the integers $p$ and $q$ ($1 \leq p \lt q \leq 10^{100}$) such that the $p$-th and $q$-th bits of the lexicographically maximal $t$ are $\texttt{1}$.

翻译中…

Note

翻译中…

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 $\texttt{1}$, so it is impossible.

翻译中…

样例

Input #1
1
Output #1
1 2
InputCopy OutputCopy
Input #2
001
Output #2
3 4
InputCopy OutputCopy
Input #3
1111
Output #3
1 5
InputCopy OutputCopy
Input #4
00000
Output #4
-1
InputCopy OutputCopy
Input #5
00000111110000011111000001111101010
Output #5
6 37452687
InputCopy OutputCopy
题目信息
题号
1698G
时间限制
2 s
内存限制
256 MB
标签
位运算
数学
矩阵
折半搜索
数论

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。