Logo
(追記) (追記ここまで)

34649번 - Brain Power 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 1024 MB91726583.333%

문제

You are given a string $s$ consisting of lowercase English letters. Your task is to split $s$ into a sequence of non-empty substrings such that no two adjacent substrings in the sequence are anagrams of each other. (Two strings are considered anagrams if they contain the same characters with the same frequencies.) Among all such valid splits, you must maximize the number of substrings.

입력

The first line of the input contains a single integer $T,ドル the number of test cases.

The following $T$ lines each describe a test case. Each line contains a single string $s$ consisting of lowercase English letters.

출력

For each test case, print a single integer on a new line: the maximum possible number of substrings in a valid split.

제한

  • 1ドル \le T \le 10^5$
  • 1ドル \le |s| \le 10^5$ for each test case.
  • The total length of all strings $s$ over all test cases does not exceed 10ドル^5$.

예제 입력 1

5
kaist
rrunnn
iiccppcc
mooockk
connttest

예제 출력 1

5
4
6
5
8

예제 입력 2

8
a
bb
ccc
dddd
eeeee
ffffff
ggggggg
hhhhhhhh

예제 출력 2

1
1
2
3
3
4
5
5

예제 입력 3

4
brainpowerletthebasskick
oooooooooooaaaaeaaiau
joooooooooooooaaeoaauua
eeeeeeeeeaaaaeaeiea

예제 출력 3

22
15
17
15

노트

출처

University > KAIST > KAIST ICPC Mock Competition > 2025 KAIST 15th ICPC Mock Competition B번

University > MIT > The MIT Programming Contest > 2025-26 > MIT Team Contest 2 B번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /