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. C#匿名对象在其它方法体内怎么取到相应的值(不想建立对应的类并转化的情况下)?

    public object AnonymousObj() { ", Message = "OK", Data = new {...} } } public void Ot ...

  2. Oracle Data Integrator 12cR1 (12.1.3.0.0)安装过程

    Oracle Data Integrator 12cR1 (12.1.3.0.0)安装过程 下载安装文件 Oracle Data Integrator 12cR1 (12.1.3.0.0) http: ...

  3. Oracle单引号双重角色——字符串引用与转义

    单引号双重角色——字符串引用与转义      在ORACLE中,单引号有两个作用,一是字符串是由单引号引用,二是转义,开始学习时动态构成SQL时经常不解.单引号的使用是就近配对,即就近原则.而在单引号 ...

  4. Java一个枚举类的2种实现。

    实现方式一: public enum Operation { PLUS, MINUS, TIMES, DIVIDE; double apply(double x, double y) { switch ...

  5. Android玩转百度地图Sha1获取正确姿势?

    场景一 由于近期项目钟要用到定位功能因此肯定须要用到地图以及地位功能,相信大家也知道眼下国内比較出名的地图像百度.高德.腾讯等这些还是用到比較多的.于是思考了一下决定还是用百度,相信老司机们都知道的哈 ...

  6. 2011的n次方

    题目:http://noi.openjudge.cn/ch0204/2991/ 总时间限制:1000ms  内存限制: 65536kB 描述 已知长度最大为200位的正整数n,请求出2011^n的后四 ...

  7. Eclipse和MyEclipse使用技巧--如何解决新建一个包的时候,工具帮生成了多个包的问题?

    一.问题再现 二.如何解决

  8. Maven+Nexus+Jenkins+Svn+Tomcat+Sonar搭建持续集成环境

    使用Maven+Nexus+Jenkins+Svn+Tomcat+Sonar搭建持续集成环境(一) 2015-01-14 20:28 by 飘扬的红领巾, 4322 阅读, 5 评论, 收藏, 编辑 ...

  9. 分布式 并行软件平台 Dryad Hadoop HPCC

    1.为了 能够方便记忆, 总结一下. 2.  并行软件平台,不是 一个. (1)这个特别熟悉的 以 hadoop 为平台的 生态系统 (2)还有以 微软的 并行软件平台 生态系统 (3) 还有Lexi ...

  10. Window10激活

    Windows10激活,通过kms激活. 01.安装对应版本的秘钥 专业版:W269N-WFGWX-YVC9B-4J6C9-T83GX 企业版:NPPR9-FWDCX-D2C8J-H872K-2YT4 ...