#B3920. Counting Genshin and Player Substring Pairs
Counting Genshin and Player Substring Pairs
Counting Genshin and Player Substring Pairs
You are given a string \( s \) of length \( |s| \). You are to count the number of ways to choose two substrings \( s[l_1, r_1] \) and \( s[l_2, r_2] \) from \( s \) such that:
- \( 1 \le l_1 \le r_1 \le l_2 \le r_2 \le |s| \);
- \( s[l_1, r_1] = \texttt{Genshin} \);
- \( s[l_2, r_2] = \texttt{player} \).
Two selections are considered different if at least one of the indices \( l_1, r_1, l_2, r_2 \) differs.
Note: The substring \( s[l_1, r_1] \) is defined as the sequence of characters from the \( l_1 \)th to the \( r_1 \)th character of \( s \) (both endpoints inclusive). Similarly for \( s[l_2, r_2] \).
Find the number of valid pairs of positions that satisfy the above conditions.
inputFormat
The input consists of a single line containing a non-empty string \( s \). The string can contain any characters.
outputFormat
Output a single integer, denoting the number of valid pairs of substrings \( (s[l_1, r_1], s[l_2, r_2]) \) that meet the conditions.
sample
Genshinplayer
1