CF1620A.Equal or Not Equal

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You had nn positive integers a1,a2,,ana_1, a_2, \dots, a_n arranged in a circle. For each pair of neighboring numbers ( a1a_1 and a2a_2 , a2a_2 and a3a_3 , ..., an1a_{n - 1} and ana_n , and ana_n and a1a_1 ), you wrote down: are the numbers in the pair equal or not.

Unfortunately, you've lost a piece of paper with the array aa . Moreover, you are afraid that even information about equality of neighboring elements may be inconsistent. So, you are wondering: is there any array aa which is consistent with information you have about equality or non-equality of corresponding pairs?

输入格式

The first line contains a single integer tt ( 1t10001 \le t \le 1000 ) — the number of test cases. Next tt cases follow.

The first and only line of each test case contains a non-empty string ss consisting of characters E and/or N. The length of ss is equal to the size of array nn and 2n502 \le n \le 50 . For each ii from 11 to nn :

  • if si=s_i = E then aia_i is equal to ai+1a_{i + 1} ( an=a1a_n = a_1 for i=ni = n );
  • if si=s_i = N then aia_i is not equal to ai+1a_{i + 1} ( ana1a_n \neq a_1 for i=ni = n ).

输出格式

For each test case, print YES if it's possible to choose array aa that are consistent with information from ss you know. Otherwise, print NO.

It can be proved, that if there exists some array aa , then there exists an array aa of positive integers with values less or equal to 10910^9 .

输入输出样例

  • 输入#1

    4
    EEE
    EN
    ENNEENE
    NENN

    输出#1

    YES
    NO
    YES
    YES

说明/提示

In the first test case, you can choose, for example, a1=a2=a3=5a_1 = a_2 = a_3 = 5 .

In the second test case, there is no array aa , since, according to s1s_1 , a1a_1 is equal to a2a_2 , but, according to s2s_2 , a2a_2 is not equal to a1a_1 .

In the third test case, you can, for example, choose array a=[20,20,4,50,50,50,20]a = [20, 20, 4, 50, 50, 50, 20] .

In the fourth test case, you can, for example, choose a=[1,3,3,7]a = [1, 3, 3, 7] .

首页