#P15782. [JAG 2025 Summer Camp #3] Word Search

[JAG 2025 Summer Camp #3] Word Search

题目描述

You are given a word SS 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 SS into several contiguous substrings that are syllables, determine the minimum and maximum possible number of distinct syllables among them.

输入格式

The input consists of multiple test cases.

The first line contains an integer TT (1T100001 \leq T \leq 10000), representing the number of test cases.

TT test cases follow. Each test case is given in the following format.

SS

For each test case, the only line contains a string SS (1S1061 \leq |S| \leq 10^6), consisting of uppercase and lowercase English letters.

Additionally, the sum of the lengths of SS over all test cases does not exceed 10610^6.

输出格式

Output TT lines. For each test case, output the minimum and maximum possible numbers of distinct syllables in SS, in this order, separated by a space.

3
RaRa
ICPCJAG
BuRiShaBuShaBuRiBu
1 3
6 6
4 10

提示

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 11, 33, 33, and 22, respectively. Therefore, the minimum is 11 and the maximum is 33.