CF1620A.Equal or Not Equal
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You had n positive integers a1,a2,…,an arranged in a circle. For each pair of neighboring numbers ( a1 and a2 , a2 and a3 , ..., an−1 and an , and an and a1 ), you wrote down: are the numbers in the pair equal or not.
Unfortunately, you've lost a piece of paper with the array 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 which is consistent with information you have about equality or non-equality of corresponding pairs?
输入格式
The first line contains a single integer t ( 1≤t≤1000 ) — the number of test cases. Next t cases follow.
The first and only line of each test case contains a non-empty string s consisting of characters E and/or N. The length of s is equal to the size of array n and 2≤n≤50 . For each i from 1 to n :
- if si= E then ai is equal to ai+1 ( an=a1 for i=n );
- if si= N then ai is not equal to ai+1 ( an=a1 for i=n ).
输出格式
For each test case, print YES if it's possible to choose array a that are consistent with information from s you know. Otherwise, print NO.
It can be proved, that if there exists some array a , then there exists an array a of positive integers with values less or equal to 109 .
输入输出样例
输入#1
4 EEE EN ENNEENE NENN
输出#1
YES NO YES YES
说明/提示
In the first test case, you can choose, for example, a1=a2=a3=5 .
In the second test case, there is no array a , since, according to s1 , a1 is equal to a2 , but, according to s2 , a2 is not equal to a1 .
In the third test case, you can, for example, choose array a=[20,20,4,50,50,50,20] .
In the fourth test case, you can, for example, choose a=[1,3,3,7] .