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 ...
随机推荐
- 记:青岛理工ACM交流赛筹备工作总结篇
这几天筹备青岛理工ACM交流赛的过程中遇到了不少问题也涨了不少经验.对非常多事也有了和曾经不一样的看法, 一直在想事后把这几天的流水帐记一遍,一直没空直到今天考完C++才坐下来開始动笔.将这几天的忙 ...
- JS 拦截/捕捉 全局错误 全局Error onerror
移动Web开发过程中,在真机测试时,往往会遇到一些PC调试无法重现的问题,这时候我们需要在手机上拦截错误,并有相应的输出. 公司和网上都有类似的工具/类库,但如果纯粹一个简单的调试,或许不需要引入工具 ...
- 感谢大家对《Cocos2d-JS开发之旅》的支持
昨天收到一封读者的来信,给我报了个喜,也提了一些非常好的建议. 他通过短短1个月时间就完成了学习和游戏开发,并发布了Android和iOS平台,真了不起.授人以鱼不如授人以渔,这也是写书的最大喜悦吧. ...
- ThreadLocal MDC
因为MDC底层是用ThreadLocal实现的,所以这里补充一些和ThreadLocal相关的知识点. 1.ThreadLocal的三个层次 关于ThreadLocal有三个层次,可以按照这三个层次去 ...
- visual studio运行时库MT、MTd、MD、MDd的研究
在开发window程序是经常会遇到编译好好的程序拿到另一台机器上面无法运行的情况,这一般是由于另一台机器上面没有安装响应的运行时库导致的,那么这个与编译选项MT.MTd.MD.MDd有什么关系呢?这是 ...
- vi编辑器的常用命令
游标控制 h 游标向左移 j 游标向下移 k 游标向上移 l (or spacebar) 游标向右移 w 向前移动一个单词 b 向后移动一个单词 e 向前移动一个单词,且游标指向单词的末尾 ( 移到当 ...
- python3 数据库查询
#xiaodeng #python 3 #数据库查询 #第一种方法(fethall,返回所有行数据) import pymysql #connect链接服务器,注意和服务库编码一致 conn=pymy ...
- mysql: SELECT ... FOR UPDATE 对SELECT语句的阻塞实验
开两个连接A, B, 分别执行以下三个sql start 和 start ; 在A执行完1和2后, B执行1, 正常B执行2, 立即返回B执行3, 这时候被阻塞了 A执行3后, B的3立即返回 可以得 ...
- PLSQL Developer启动失败
原因:和打印服务冲突 禁掉打印服务,不过打印功能是不行了
- JavaMail 接收邮件及删除
解析读取收件箱中邮件: import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io. ...