#P16602. [SYSUCPC 2025] SYSU II

    ID: 16371 Type: RemoteJudge 1000ms 256MiB Tried: 0 Accepted: 0 Difficulty: 5 Uploaded By: Tags>2025哈希 hashing前缀和高校校赛

[SYSUCPC 2025] SYSU II

题目描述

As you all know, you are participating in the SYSUCPC (SYSU Counting Periodic-string Contest) finals.

A string is considered good\bf{good} if and only if it can be rearranged into a perfectly periodic string with sysu\texttt{sysu} as its period (which means several sysu\texttt{sysu} repetitions). For example, sysu,yssu,ssyyssuu\texttt{sysu,yssu,ssyyssuu} are all good\bf{good}, while ussu, sysusys\texttt{ussu, sysusys} are not. Given a string SS, determine how many of its substrings are good\bf{good}.

A string aa is a substring of a string bb if aa can be obtained from bb by the deletion of several (possibly zero or all) characters from the beginning and several (possibly zero or all) characters from the end.

输入格式

The only line contains a single string S(4S2×105)S(4\le |S|\le 2\times 10^5). It is guaranteed that SS only contains lowercase English letters.

输出格式

An integer, representing the number of good\bf{good} substrings of SS.

ilovesysusysu
6

提示

There are 66 good\bf{good} substrings : sysu,ysus,susy,usys,sysu,sysusysu\texttt{sysu,ysus,susy,usys,sysu,sysusysu}.