Polycarp has a poor memory. Each day he can remember no more than 3 of different letters.
Polycarp wants to write a non-empty string of s consisting of lowercase Latin letters, taking minimum number of days. In how many days will he be able to do it?
Polycarp initially has an empty string and can only add characters to the end of that string.
For example, if Polycarp wants to write the string lollipops, he will do it in 2 days:
If Polycarp wants to write the string stringology, he will do it in 4 days:
For a given string s, print the minimum number of days it will take Polycarp to write it.
Polycarp 的記憶力很差。 每天他能記住的不同字母不超過 3 個。
Polycarp 想要寫一個由小寫拉丁字母組成的非空字符串 s,需要最少的天數。 幾天后他能做到?
Polycarp 最初有一個空字符串,並且只能在該字符串的末尾添加字符。
比如Polycarp想寫字符串 lollipops,他會在2天內完成:
第一天,Polycarp 會記住字母 l、o、i 並寫出 lolli;
第二天,Polycarp 將記住字母 p、o、s,將 pops 添加到結果行中並得到 lollipops。
如果 Polycarp 想寫 stringology,他會在 4 天內完成:
第一天將寫 str;
第二天將寫 ing;
第三天將寫 olog;
第四天,y 被寫入。
對於給定的字符串 s,打印 Polycarp 編寫它所需的最少天數。
The first line of input data contains a single integer t (1 ≤ t ≤ 104) — the number of test cases.
Each test case consists of a non-empty string s consisting of lowercase Latin letters (the length of the string s does not exceed 2⋅105) — the string Polycarp wants to construct.
It is guaranteed that the sum of string lengths s over all test cases does not exceed 2⋅105.
輸入數據的第一行包含一個整數 t (1 ≤ t ≤ 104) — 測試用例的數量。
每個測試用例都包含一個由小寫拉丁字母組成的非空字符串 s(字符串 s 的長度不超過 2⋅105)——Polycarp 想要構建的字符串。
保證所有測試用例的字符串長度總和 s 不超過 2⋅105。
For each test case, print a single number — minimum number of days it will take Polycarp to write the string s from memory.
對於每個測試用例,打印一個數字 — Polycarp 從內存中寫入字符串 s 所需的最少天數。
6 lollipops stringology abracadabra codeforces test f
2 4 3 4 1 1
ID | User | Problem | Subject | Hit | Post Date |
沒有發現任何「解題報告」 |