CF1698G.Long Binary String

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

There is a binary string tt of length 1010010^{100} , and initally all of its bits are 0\texttt{0} . You are given a binary string ss , and perform the following operation some times:

  • Select some substring of tt , and replace it with its XOR with ss . ^\dagger

After several operations, the string tt has exactly two bits 1\texttt{1} ; that is, there are exactly two distinct indices pp and qq such that the pp -th and qq -th bits of tt are 1\texttt{1} , and the rest of the bits are 0\texttt{0} . Find the lexicographically largest ^\ddagger string tt satisfying these constraints, or report that no such string exists.

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

^\ddagger A binary string aa is lexicographically larger than a binary string bb of the same length if in the first position where aa and bb differ, the string aa has a bit 1\texttt{1} and the corresponding bit in bb is 0\texttt{0} .

输入格式

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

输出格式

If no string tt exists as described in the statement, output -1. Otherwise, output the integers pp and qq ( 1p<q101001 \leq p < q \leq 10^{100} ) such that the pp -th and qq -th bits of the lexicographically maximal tt are 1\texttt{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 tt are the lexicographically largest ones.

In the fourth test, you can't make a single bit texttt1\\texttt{1}$$, so it is impossible.

首页