题目链接: 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;
}