#P15782. [JAG 2025 Summer Camp #3] Word Search
[JAG 2025 Summer Camp #3] Word Search
Description
You are given a word written in an unfamiliar language. In this language, a syllable is known to be one of the following:
- A single uppercase English letter
- A single lowercase English letter
- An uppercase English letter followed by a lowercase English letter
For example, "Ab", "A", and "c" can each form a syllable, but "IC", "pC", and "Jag" cannot.
When dividing a word into several contiguous substrings that are syllables, determine the minimum and maximum possible number of distinct syllables among them.
Input Format
The input consists of multiple test cases.
The first line contains an integer (), representing the number of test cases.
test cases follow. Each test case is given in the following format.
For each test case, the only line contains a string (), consisting of uppercase and lowercase English letters.
Additionally, the sum of the lengths of over all test cases does not exceed .
Output Format
Output lines. For each test case, output the minimum and maximum possible numbers of distinct syllables in , in this order, separated by a space.
3
RaRa
ICPCJAG
BuRiShaBuShaBuRiBu
1 3
6 6
4 10
Hint
In the first test case, the word “RaRa” can be divided into syllables in the following ways: “Ra” + “Ra”, “Ra” + “R” + “a”, “R” + “a” + “Ra”, and “R” + “a” + “R” + “a”. Here, + denotes string concatenation. For each division, the number of distinct syllables is , , , and , respectively. Therefore, the minimum is and the maximum is .
京公网安备 11011102002149号