#K56057. Interesting String Partition
Interesting String Partition
Interesting String Partition
Given a string ( S ), determine if it can be partitioned into exactly two contiguous substrings such that each substring consists solely of one distinct character and the two characters are different. Formally, we need to check if ( S = A^mB^n ), where ( A ) and ( B ) are characters with ( A \neq B ) and ( m, n \geq 1 ). If such a partition exists, output "YES", otherwise output "NO".
Example: For ( S = \texttt{aaabbb} ), the partition would be ( \texttt{aaa} ) and ( \texttt{bbb} ), so the answer is "YES".
inputFormat
The first line contains an integer ( T ) denoting the number of test cases. Each of the following ( T ) lines contains a single string ( S ).
outputFormat
For each test case, output "YES" if the string ( S ) can be partitioned into exactly two blocks of contiguous, identical characters (with the blocks consisting of two different characters), otherwise output "NO". Each answer should be printed on a new line.## sample
3
aaabbb
aabb
abc
YES
YES
NO
</p>