Command
InterviewTime limit0.5sMemory limit256 MB
For each of T strings, decide whether it has length 7 and its characters follow the exact pattern AABBABB with exactly two distinct letters.
- Level
Easy2 of 10
- Topics
- String, Implementation, Hash map
- Solved
- No attempts yet
Problem
Yunpyo, who usually enjoys a video game called Hexa Dungeon, is especially fond of the combo performed by entering the keys AABBABB.
The console has countless keys, so the commands that can be created are just as varied. Having mastered the game, Yunpyo grew bored and tried commands with the same form but different characters, such as BBCCBCC and CCDDCDD, and found that they let him use different skills.
So Yunpyo defined a command Yunpyo likes.
- The length of the string is 7.
- The string consists of exactly 2 kinds of characters.
- It satisfies the form AABBABB.
Delighted by this, Yunpyo wrote a macro that generates commands, but his coding skill was too lacking to make it generate only commands Yunpyo likes. Watching this with frustration, Seoyun intends to write a program that checks whether a given command is a command Yunpyo likes.
Input
The first line gives the number of test cases T. (1 ≤ T ≤ 100)
The following T lines each give a string of length N consisting only of uppercase letters. N is a natural number less than or equal to 10,000.
Output
For each of the T test cases, print 1 if it is a command Yunpyo likes and 0 otherwise, one per line.