#P16771. [GKS 2020 #G] Kick_Start

    ID: 17032 Type: RemoteJudge 1000ms 1024MiB Tried: 0 Accepted: 0 Difficulty: 3 Uploaded By: Tags>字符串数学2020Google Kick Start

[GKS 2020 #G] Kick_Start

题目描述

Ksenia is very fond of reading so she kicks off each day by reading a fragment from her favourite book before starting with the rest of her morning routine. A fragment is simply a substring of the text. Ksenia is somewhat superstitious and believes that her day will be lucky if the fragment she reads starts with the string KICK, then goes on with 00 or more characters, and eventually ends with the string START, even if the overall fragment makes little sense.

Given the text of the book, count the number of different lucky fragments that Ksenia can read before the book gets old and she needs to buy another one. Two fragments are considered to be different if they start or end at different positions in the text, even if the fragments read the same. Also note that different lucky fragments may overlap.

输入格式

The first line of the input gives the number of test cases TT. TT lines follow, each containing a single string SS consisting of upper case English letters only.

输出格式

For each test case, output one line containing Case #xx: yy, where xx is the test case number (starting from 11) and yy is the number of different lucky fragments in the text of this test case.

3
AKICKSTARTPROBLEMNAMEDKICKSTART
STARTUNLUCKYKICK
KICKXKICKXSTARTXKICKXSTART
Case #1: 3
Case #2: 0
Case #3: 5

提示

There are three lucky fragments in the first test case, namely, KICKSTARTPROBLEMNAMEDKICKSTART and two occurrences of KICKSTART. The text in the second test case has no lucky fragments at all.

Limits

1≤T≤1001 \le T \le 100.

SS consists of upper-case English letters only.

Test Set 11

1≤∣S∣≤10001 \le |S| \le 1000.

Test Set 22

1≤∣S∣≤1051 \le |S| \le 10^5.