天天看点

HDU 5284 wyh2000 and a string problem

Problem Description

Young theoretical computer scientist wyh2000 is teaching young pupils some basic concepts about strings.

A subsequence of a string s is a string that can be derived from s

He also teaches the pupils how to determine if a string is a subsequence of another string. For example, when you are asked to judge whether wyh is a subsequence of some string or not, you just need to find a character w, a y, and an h, so that the w is in front of the y, and the y is in front of the h.

One day a pupil holding a string asks him, "Is wyh a subsequence of this string?" However, wyh2000 has severe myopia. If there are two or more consecutive charactervs, then he would see it as one w. For example, the string vvv will be seen as w, the string vvwvvv will be seen as www, and the string vwvv will be seen as vww.

How would wyh2000 answer this question?

Input

The first line of the input contains an integer T(T≤105), denoting the number of testcases.

N

Total string length will not exceed 3145728. Strings contain only lowercase letters.

The length of hack input must be no more than 100000.

Output

For each string, you should output one line containing one word. Output Yes if wyh2000 would consider wyh as a subsequence of it, or No

Sample Input

4

woshiyangli

woyeshiyangli

vvuuyeh

vuvuyeh

Sample Output

No

Yes

Yes

No

#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<string>
using namespace std;
const int maxn = 5000005;
int T, n, m;
char s[maxn];

int main()
{
    cin >> T;
    while (T--)
    {
        scanf("%s", s);
        int f[3] = {0};
        for (int i = 0; s[i]; i++)
        {
            if (s[i] == 'w') f[0] = 1;
            if (s[i] == 'v'&&s[i + 1] == 'v') f[0] = 1;
            if (s[i] == 'y'&&f[0]) f[1] = 1;
            if (s[i] == 'h'&&f[1]) f[2] = 1;
        }
        if (f[2]) printf("Yes\n");
        else printf("No\n");
    }
    return 0;
}