MOJ Round #3Ended |
Imagine an string $S$ with length $N$ where each character in numbered from $0$ to $N - 1$. If you take two integers $i$, $j$; $0 \leq i \lt j \leq N$ and the magic function $\text{F}$ you can get the following string:
$\text{F}(S, i, j) = s[i + 1…j - 1] + \text{r}(s[j…N-1]) + \text{r}(s[0…i])$
If $j = i + 1$ then the substring $s[i + 1…j - 1]$ is considered empty.
You are given two strings $A$ and $B$. Find two values $i$, $j$ that $\text{F}(A,i,j) = B$. Number $i$ sould be as big as possible. If for this $i$ you have several valid values for $j$, chose the minimal $j$.
Two lines, one string on each line. The length of both string is not greater than $10^6$ characters. The string contains any character with ASCII code from $32$ to $126$ inclusive.
Two integers, the values for $i$ and $j$. if no solution is possible print $\texttt{“-1 -1”}$ without the quotes.