All submissions for this problem are available.
Read problems statements in Mandarin Chinese , Russian and Vietnamese as well.
Sergey recently learned about country codes - two letter strings, denoting countries. For example, BY stands for Belarus and IN stands for India. Mesmerized by this new discovery, Sergey now looks for country codes everywhere!
Sergey has recently found a string S consisting of uppercase Latin letters. He wants to find the number of different country codes that appear in S as contiguous substrings. For the purpose of this problem, consider that every 2-letter uppercase string is a valid country code.
The first line of input contains an integer T denoting the number of test cases. The description of T test cases follows.
The first and only line of each test case contains a string S, consisting of uppercase Latin letters.
For each test case, output a single line containing the number of different country codes appearing in the given string.
- 1 ≤ T ≤ 100
- Subtask 1 (35 points): 2 ≤ |S| ≤ 3
- Subtask 2 (65 points): 2 ≤ |S| ≤ 104
Input: 2 INBY BYBY Output: 3 2
Example case 1. The codes are IN, NB and BY.
Example case 2. The codes are BY and YB.
|Tags||basic, basics, cakewalk, constructions, language, ltime31, xcwgf666|
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, SCM chicken, PYP3, CLOJ, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.