Educational Codeforces Round 119 (Rated for Div. 2) A. Equal or Not Equal

题目链接: Problem - A - Codeforces

You had nn 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 aa which is consistent with information you have about equality or non-equality of corresponding pairs?

Input

The first line contains a single integer tt (1≤t≤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 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).

Output

For each test case, print YES if it's possible to choose array a that are consistent with information from ss 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.

Example

input

4
EEE
EN
ENNEENE
NENN

output

YES
NO
YES
YES

Note

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

In the second test case, there is no array aa, 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].

题意:有一个序列首尾相连,如果两数相等就是E,负责N现在给定字符序列,问是否存在这样的数字序列

思路:如果这个序列只有一个N那么数字序列怎么样都不可能,如果其他情况,都可以构造出来

#include<bits/stdc++.h>
using namespace std;


int main(){
	int t;
	cin >> t;
	string s;
	while(t--){
		cin >> s;
		int len = s.length();
		int a = 0;
		for(int i = 0; i < len; i++){
			if(s[i] == 'N'){
				a++;
			} 
		}
		if(a == 1){
			cout << "NO" << endl;
		} else{
			cout << "YES" << endl;
		}
	}
	return 0;
}

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值