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. Web工程中各类地址的写法

    1)总体原则 在java web开发中,只要是url地址,那么最好以“/”开头,也就是绝对路径的方式.那么这个“/”到底代表什么呢? 如果“/”是给服务器用的,则代表当前web工程:如果是给浏览器用的 ...

  2. 修改windows默认的远程连接端口

    打开注册表,找到以下路径项,并修改为你想要的端口,重启服务器即可. HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Terminal Serve ...

  3. Highcharts X轴纵向显示

    xAxis: { categories: ['苹果', '橘子', '梨', '葡萄', '香蕉'], labels:{ rotation: 90, style:{ fontSize: '13px', ...

  4. 存储过程—导出table数据为inser sqlt语句

    Sql Server Management Studio没有将table中数据导出为insert语句的功能. 下面一个很有用的存储过程,可以把某张表的数据导出为insert sql语句.当然Oracl ...

  5. Kafka流处理平台

    1. Kafka简介 Kafka是最初由Linkedin公司开发,是一个分布式.支持分区的(partition).多副本的(replica),基于zookeeper协调的分布式消息系统,它的最大的特性 ...

  6. ios判断是否有中文

    //判断是否有中文 -(BOOL)IsChinese:(NSString *)str { ; i< [str length];i++){ int a = [str characterAtInde ...

  7. 国内最火的五款HTML5前端开发框架

    2013-04-11 本文主要为大家推荐五款国内最火的HTML5前端开发框架,它们分别是腾讯团队开发的JX.淘宝团队开发的KISSY.百度团队开发的QWrap和Tangram,以及上海康尚实验室推出的 ...

  8. df看到的文件系统容量跟parted看到的分区容量差别较大的解决方法

    下午同事在自己的开发机上遇到题目说到的问题,它看到挂在到/dev/sda磁盘分区5上的ext4文件系统的容量显著小于该分区的大小 df看到的文件系统容量: #df -h /dev/sda5 Files ...

  9. hibernate关联映射注解

    转自:hibernate annotation注解方式来处理映射关系 在hibernate中,通常配置对象关系映射关系有两种,一种是基于xml的方式,另一种是基于annotation的注解方式,熟话说 ...

  10. 使用安全rm

    rm命令像一把刀子一样,玩不好会伤到自己.不要觉得自己头脑清醒,人总有犯迷糊的时候. 在.bashrc中设置PATH=/home/me/bin/:$PATH 在自己的bin目录下,添加rm脚本mv - ...