Young theoretical computer scientist wyh2000 is teaching young pupils some basic concepts about strings.
A subsequence of a string s s is a string that can be derived from s s by deleting some characters without changing the order of the remaining characters. You can delete all the characters or none, or only some of the characters.
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 wyh is a subsequence of some string or not, you just need to find a character w w , a y y , and an h h , so that the w w is in front of the y y , and the y y is in front of the h h .
One day a pupil holding a string asks him, "Is wyh wyh a subsequence of this string?"
However, wyh2000 has severe myopia. If there are two or more consecutive character v v s, then he would see it as one w w . For example, the string vvv vvv will be seen as w w , the string vvwvvv vvwvvv will be seen as www www , and the string vwvv vwvv will be seen as vww vww .
How would wyh2000 answer this question? Input
The first line of the input contains an integer
T(T≤105)
T(T≤105)
, denoting the number of testcases.
N N lines follow, each line contains a string.
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
Yes
if wyh2000 would consider
wyh
wyh
as a subsequence of it, or
No
No
otherwise.
Sample Input
Sample Output
A subsequence of a string s s is a string that can be derived from s s by deleting some characters without changing the order of the remaining characters. You can delete all the characters or none, or only some of the characters.
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 wyh is a subsequence of some string or not, you just need to find a character w w , a y y , and an h h , so that the w w is in front of the y y , and the y y is in front of the h h .
One day a pupil holding a string asks him, "Is wyh wyh a subsequence of this string?"
However, wyh2000 has severe myopia. If there are two or more consecutive character v v s, then he would see it as one w w . For example, the string vvv vvv will be seen as w w , the string vvwvvv vvwvvv will be seen as www www , and the string vwvv vwvv will be seen as vww vww .
How would wyh2000 answer this question? Input
N N lines follow, each line contains a string.
Total string length will not exceed 3145728. Strings contain only lowercase letters.
The length of hack input must be no more than 100000.
4
woshiyangli
woyeshiyangli
vvuuyeh
vuvuyeh
No
Yes
Yes
No
水题 理解题意 按描述处理字符串....
AC代码:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
char s[4000005];
int main()
{
int t,temp[5],i,n;
scanf("%d",&t);
getchar();
while(t--)
{
gets(s);
n=strlen(s);
memset(temp,0,sizeof(temp));
for(i=0;i<n;i++)
{
if(s[i]=='w'||(s[i]=='v'&&s[i+1]=='v'))
{
temp[1]++;
}
else if(s[i]=='y'&&temp[1]!=0)
{
temp[2]++;
}
else if(s[i]=='h'&&temp[1]!=0&&temp[2]!=0)
{
temp[3]++;
}
if(temp[1]!=0&&temp[2]!=0&&temp[3]!=0)
{
printf("Yes\n");
break;
}
}
if(temp[1]==0||temp[2]==0||temp[3]==0)
{
printf("No\n");
}
}
return 0;
}