Posts

Showing posts from January, 2022

A. Equal or Not Equal

A.Equal or Not Equal: You had  n n  positive integers  a 1 , a 2 , … , a n a 1 , a 2 , … , a n  arranged  in a circle . For each pair of neighboring numbers ( a 1 a 1  and  a 2 a 2 ,  a 2 a 2  and  a 3 a 3 , ...,  a n − 1 a n − 1  and  a n a n , and  a n a n  and  a 1 a 1 ), you wrote down: are the numbers in the pair equal or not. Unfortunately, you've lost a piece of paper with the array  a a . Moreover, you are afraid that even information about equality of neighboring elements may be inconsistent. So, you are wondering: is there any array  a a  which is consistent with information you have about equality or non-equality of corresponding pairs? Input The first line contains a single integer  t t  ( 1 ≤ t ≤ 1000 1 ≤ t ≤ 1000 ) — the number of test cases. Next  t t  cases follow. The first and only line of each test case contains a non-empty string  s s  con...