T8

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const int maxn=1e6+5;
const int maxm=1e6;
char str[maxn];
int main() {
    cin >> str + 1;
    int n = strlen(str + 1);
    for (int i = 1; i <= n; i++) {
        if (str[i] == 'W' && str[i + 1] == 'J') {
            for (int j = 1; j < i; j++) {
                if (str[j] == 'W' && str[j - 1] == 'J') {
                    cout << "YES" << endl; return 0;
                }
            }    
            for (int j = i + 2; j <= n; j++) {
                if (str[j] == 'J' && str[j + 1] == 'W') {
                    cout << "YES" << endl; return 0;
                }
            }
        }
    }
    cout << "NO" << endl;
    return 0;
}

全部评论

相关推荐

牛至超人:您好,京东物流岗了解一下吗?负责精加工食品的端到端传输
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务