Upload code_segments/segment_92.txt with huggingface_hub
Browse files- code_segments/segment_92.txt +19 -0
code_segments/segment_92.txt
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
You are given a string $s$ consisting of lowercase Latin characters. Count the number of nonempty strings $t \neq$ "$\texttt{a}$" such that it is possible to partition$^{\dagger}$ $s$ into some substrings satisfying the following conditions:
|
2 |
+
|
3 |
+
* each substring either equals $t$ or "$\texttt{a}$", and * at least one substring equals $t$.
|
4 |
+
|
5 |
+
$^{\dagger}$ A partition of a string $s$ is an ordered sequence of some $k$ strings $t_1, t_2, \ldots, t_k$ (called substrings) such that $t_1 + t_2 + \ldots + t_k = s$, where $+$ represents the concatenation operation.
|
6 |
+
|
7 |
+
The first line contains a single integer $t$ ($1 \leq t \leq 10^4$) — the number of test cases.
|
8 |
+
|
9 |
+
The only line of each test case contains a string $s$ consisting of lowercase Latin characters ($2 \leq |s| \leq 2 \cdot 10^5$).
|
10 |
+
|
11 |
+
The sum of $|s|$ over all test cases does not exceed $3 \cdot 10^5$.
|
12 |
+
|
13 |
+
For each test case, output a single integer — the number of nonempty strings $t \neq$ "$\texttt{a}$" that satisfy all constraints.
|
14 |
+
|
15 |
+
In the first test case, $t$ can be "$\texttt{aa}$", "$\texttt{aaa}$", "$\texttt{aaaa}$", or the full string.
|
16 |
+
|
17 |
+
In the second test case, $t$ can be "$\texttt{b}$", "$\texttt{bab}$", "$\texttt{ba}$", or the full string.
|
18 |
+
|
19 |
+
In the third test case, the only such $t$ is the full string.
|