All submissions for this problem are available.
Read problems statements in Mandarin Chinese and Russian.
Every day, Mike goes to his job by a bus, where he buys a ticket. On the ticket, there is a letter-code that can be represented as a string of upper-case Latin letters.
Mike believes that the day will be successful in case exactly two different letters in the code alternate. Otherwise, he believes that the day will be unlucky. Please see note section for formal definition of alternating code.
You are given a ticket code. Please determine, whether the day will be successful for Mike or not. Print "YES" or "NO" (without quotes) corresponding to the situation.
The first line of the 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 single string S denoting the letter code on the ticket.
For each test case, output a single line containing "YES" (without quotes) in case the day will be successful and "NO" otherwise.
NoteTwo letters x, y where x != y are said to be alternating in a code, if code is of form "xyxyxy...".
- 1 ≤ T ≤ 100
- S consists only of upper-case Latin letters
Subtask 1 (50 points):
- |S| = 2
Subtask 2 (50 points):
- 2 ≤ |S| ≤ 100
Input: 2 ABABAB ABC Output: YES NO
|Tags||cakewalk, ltime23, 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, CLOJ, FS|
Fetching successful submissions