bestcoder 48# wyh2000 and a string problem (水题)
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
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?
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.
wyh2000 would consider wyh as
a subsequence of it, or No otherwise.
4
woshiyangli
woyeshiyangli
vvuuyeh
vuvuyeh
No
Yes
Yes
No
#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 (水题)的更多相关文章
- Codeforces - 1194B - Yet Another Crosses Problem - 水题
https://codeforc.es/contest/1194/problem/B 好像也没什么思维,就是一个水题,不过蛮有趣的.意思是找缺黑色最少的行列十字.用O(n)的空间预处理掉一维,然后用O ...
- hdu-5867 Water problem(水题)
题目链接: Water problem Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Othe ...
- poj 1658 Eva's Problem(水题)
一.Description Eva的家庭作业里有很多数列填空练习.填空练习的要求是:已知数列的前四项,填出第五项.因为已经知道这些数列只可能是等差或等比数列,她决定写一个程序来完成这些练习. Inpu ...
- HDU 5284 wyh2000 and a string problem(字符串,水)
题意:比如给你一个串,要求判断wyh是不是它的子序列,那么你只需要找一个w,找一个y,再找一个h,使得w在y前面,y在h前面即可.有一天小学生拿着一个串问他“wyh是不是这个串的子序列?”.但是wyh ...
- hdu 5284 wyh2000 and a string problem(没有算法,仅仅考思维,字符数组得开20万,不然太小了)
代码: #include<cstdio> #include<cstring> using namespace std; char s[200000]; int main() { ...
- Poj1207 The 3n + 1 problem(水题(数据)+陷阱)
一.Description Problems in Computer Science are often classified as belonging to a certain class of p ...
- BestCoder Round #36 (hdu5198)Strange Class(水题)
转载请注明出处: http://www.cnblogs.com/fraud/ ——by fraud Strange Class Time Limit: 2000/1000 MS (J ...
- HDU 5832 A water problem 水题
A water problem 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5832 Description Two planets named H ...
- HDU 5170 GTY's math problem 水题
题目链接: hdu:http://acm.hdu.edu.cn/showproblem.php?pid=5170 bc(中文):http://bestcoder.hdu.edu.cn/contests ...
随机推荐
- Java 基础【14】@注解
1.注解简介 JDK 1.5 中引入的 java.lang.annotation 包提供注解编程支持,可以让类在编译.类加载.运行时被读取,并执行相应的处理. 在 Java EE应用的时候,总是免不了 ...
- itextpdf 备忘
加删除线: .setUnderline(Color.BLACK, 2.0f, 0.0f, 6.0f, 0.0f, 1) https://developers.itextpdf.com/examples ...
- 利用sqlserver sa更改系统密码
--允许修改高级属性 sp_configure go reconfigure go --启用扩展存储命令 sp_configure go reconfigure go --系统添加一个windows用 ...
- JAVA & Android 等待线程池内任务全部完成后退出
void shutdownAndAwaitTermination(ExecutorService pool) { pool.shutdown(); // Disable new tasks from ...
- CentOS yum时出现"Could not retrieve mirrorlist"
问题描述: CentOS 6.x minimal(最小化) 安装, CentOS yum install net-tools 时出现"Could not retrieve mirrorlis ...
- 写带有清晰图片的博客:如何将word中的图片复制到windows live writer保持大小不变--清晰度不变
写blog的习惯,先在word写了,复制到windows live writer,再发布到博客园.word中的文章,图片有缩放比例,复制到windows live writer后图片变得不清晰.除了一 ...
- Mysql中字符串正确的连接方法
虽然SQL server和My sql的语句基本都一致,但是仍然存在一些小区别.就如字符串的连接来说,SQL server中的字符串连接是使用“+”来连接,不带引号sql server是做加法运算.而 ...
- 二维码Data Matrix简单介绍及在VS2010中的编译
Data Matrix 二维条码原名Datacode,由美国国际资料公司(International Data Matrix, 简称ID Matrix)于1989年发明.Data-Matrix二维条码 ...
- 分享一个VS2008漂亮的黑色主题
如果恰巧你也使用Visual Studio 2008这个版本, 如果你也恰巧厌烦了白色的背景, 那么推荐你使用这款纯黑色theme,搭配上DroidSansMonog这个等宽字体(打包下载),每天都可 ...
- wordpress搭建博客上传begin主题The themes is locked to another domain
如题, 在使用wordpress搭建个人博客过程中, 上传begin主题, 出现如下弹框的错误, 而且样式有误. 环境: Los Angeles CentOS 7 x64 nginx+mysql 解决 ...