Brain Power
시간 제한1초메모리 제한1024 MB
소문자 문자열을 이웃한 조각끼리 애너그램이 되지 않도록 최대 개수의 비어 있지 않은 조각으로 나눈다.
문제
You are given a string consisting of lowercase English letters. Your task is to split 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 , the number of test cases.
The following lines each describe a test case. Each line contains a single string 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.
제한
- for each test case.
- The total length of all strings over all test cases does not exceed .