wyh2000 and a string problem

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/65536 K (Java/Others)

Total Submission(s): 484    Accepted Submission(s): 232

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 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 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 character vs,
then he would see it as one w.
For example, the string vvv will
be seen asw,
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 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 if
wyh2000 would consider wyh as
a subsequence of it, or No otherwise.
 
Sample Input
4
woshiyangli
woyeshiyangli
vvuuyeh
vuvuyeh
 
Sample Output
No
Yes
Yes
No
 
Source
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;
char s[40000000];
char str[5]={"wyh"};
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
scanf("%s",s); int len = strlen(s); int id=0; for(int i = 0;i < len;i++)
{
if(id==3) break;
if(s[i]==str[id]) id++;
if(id==0 && s[i]=='v' && s[i+1]=='v') id++;
}
// printf("%d\n",id);
if(id==3) printf("Yes\n");
else printf("No\n");
}
}

bestcoder 48# wyh2000 and a string problem (水题)的更多相关文章

  1. Codeforces - 1194B - Yet Another Crosses Problem - 水题

    https://codeforc.es/contest/1194/problem/B 好像也没什么思维,就是一个水题,不过蛮有趣的.意思是找缺黑色最少的行列十字.用O(n)的空间预处理掉一维,然后用O ...

  2. hdu-5867 Water problem(水题)

    题目链接: Water problem Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Othe ...

  3. poj 1658 Eva's Problem(水题)

    一.Description Eva的家庭作业里有很多数列填空练习.填空练习的要求是:已知数列的前四项,填出第五项.因为已经知道这些数列只可能是等差或等比数列,她决定写一个程序来完成这些练习. Inpu ...

  4. HDU 5284 wyh2000 and a string problem(字符串,水)

    题意:比如给你一个串,要求判断wyh是不是它的子序列,那么你只需要找一个w,找一个y,再找一个h,使得w在y前面,y在h前面即可.有一天小学生拿着一个串问他“wyh是不是这个串的子序列?”.但是wyh ...

  5. hdu 5284 wyh2000 and a string problem(没有算法,仅仅考思维,字符数组得开20万,不然太小了)

    代码: #include<cstdio> #include<cstring> using namespace std; char s[200000]; int main() { ...

  6. Poj1207 The 3n + 1 problem(水题(数据)+陷阱)

    一.Description Problems in Computer Science are often classified as belonging to a certain class of p ...

  7. BestCoder Round #36 (hdu5198)Strange Class(水题)

    转载请注明出处: http://www.cnblogs.com/fraud/          ——by fraud Strange Class Time Limit: 2000/1000 MS (J ...

  8. HDU 5832 A water problem 水题

    A water problem 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5832 Description Two planets named H ...

  9. HDU 5170 GTY's math problem 水题

    题目链接: hdu:http://acm.hdu.edu.cn/showproblem.php?pid=5170 bc(中文):http://bestcoder.hdu.edu.cn/contests ...

随机推荐

  1. [转发]如何在ASP.NET的web.config配置文件中添加MIME类型

    常常有一些特殊的MIME类型是IIS中没有的,一般来说要我们自己手动添加.如果网站经常更换服务器或者网站代码是提供给多个用户使用,那么会造成网站中用到的特殊的MIME类型要经常性的在IIS上配置.这里 ...

  2. 〖Linux〗干掉Kubuntu烦人的软件升级提示“Update notification daemon”,Your should update ..

    Kubuntu是很好使用,但是升级提示也是太烦人了,开机的时候总是显示如下画面: 使用System Load Indicator(sudo apt-get install indicator-mult ...

  3. SSM框架-使用MyBatis Generator自动创建代码

    参考:http://blog.csdn.net/zhshulin/article/details/23912615 SSM搭建的时候用到MyBatis的代码自动生成的功能,由于MyBatis属于一种半 ...

  4. 彻底抛弃脚本录制,LR脚本之使用web_custom_request函数自定义

    原文  http://www.cnblogs.com/Bonnie83/p/3525200.html 初学性能测试时候,第一步必学脚本录制,但一路下来各种录制失败.回放脚本失败的问题层出不穷,究其原因 ...

  5. Path画直线与弧线

    代码地址如下:http://www.demodashi.com/demo/14754.html 前言 之前讲过Paint和Canvas的基本使用,今天来介绍下Path的使用 涉及内容有: Path画直 ...

  6. 读书笔记--<精益和敏捷开发大型项目应用指南>

    [摘要] 3月份的时候,根据教练和其他多为项目经理的推荐,开始阅读这本书:本书共三大部分.12个章节,第一部分:思考工具,第二部分:组织工具:第三部分:杂记:全书相当于对精益思想和敏捷团队组织.Scr ...

  7. Uploadify in ASP.Net

    和分页类似,文件上传是web开发标配的技能之一.下面介绍Uploadify的配置和使用. 一.配置 首先到Uploadify官网下载,然后在项目中添加相应引用.前台代码如下: 1.jquery.js2 ...

  8. 【laravel5.4】安装predis

    1.服务器先安装redis-server,这是毋庸置疑的!!! 2.服务器开启redis-server,配置相关参数 3.laravel执行 : $  yourPhpPath composer.pha ...

  9. log4delphi使用(转)

    转自:http://blog.csdn.net/brightgems/article/details/814042 Log4d是apache下的一个delphi开源子项目,它的设计思想来源于Log4j ...

  10. 信号量 Linux函数 semget();semctl();semop();(转)

    本文出自:http://blog.csdn.net/ta893115871/article/details/7505560 Linux进程通信之信号量 信号量(semaphore)是变量,是一种特殊的 ...