시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
1 초 | 512 MB | 23 | 2 | 2 | 12.500% |
For a string $s$ consisting of only "a" and "b" , let $f(s)$ be the string obtained by replacing all "a" in $s$ with "aa" and "b" with "ab". For example, $f($"aba"$)$ = "aaabaa".
Given strings $s$ and $t$, determine the smallest non-negative integer $k$ where $t$ is a consecutive substring of $f^k(s)$.
Note that $f^k$ is defined by:
The first and second lines contain string $s$ and $t$ respectively ($1 \leq |s|, |t| \leq 2 \cdot 10^5$).
Strings $s$ and $t$ consist of only characters "a" and "b".
A single integer denotes the minimum $k$.
If $k$ does not exists, print "-1" instead.
b ab
1
ababa bab
0
a b
-1