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 ...
随机推荐
- maximum-subarray 序列最大连续和 贪心
Find the contiguous subarray within an array (containing at least one number) which has the largest ...
- 从join on和where执行顺序认识T-SQL查询处理执行顺序
先从一例子看join on 和 where执行结果的不同 CREATE TABLE "SCOTT"."A" ( "PERSON_ID" ) ...
- Java通过在主循环中判断Boolean来停止线程
Java代码: package Threads; /** * Created by Frank */ public class StopBoolean extends Thread { // 确保变化 ...
- 关于RSA加密算法的工具类
关于RSA加密算法的工具类 最近在捣鼓SSO(单点登录),就是一个在应用(系统)登录之后,当切换其他应用(系统)的时候,可以省去登录,提高用户的使用的便捷.(具体有时间在写) 期间涉及的安全问题,发送 ...
- Kinect2.0骨骼跟踪与数据平滑
Kinect v1和Kinect v2传感器的配置比较: Kinect v1 Kinect v2 颜色(Color) 分辨率(Resolution) 640×480 1920× ...
- 转error while loading shared libraries的解決方法
error while loading shared libraries的解決方法 者 icq 21:03 | 靜態連結網址 | 迴響 (0) | 引用 (1) | 點閱次數 (270) | Prog ...
- 防火墙 Firewalld
RHEL7支持的防火墙: IPTABLES IP6TABLES FIREWALL EBTABLES 命令模式: firewall-cmd 图形化界面: firewall-config Firewall ...
- linux shell 脚本攻略学习6-xargs详解
xargs是一条Unix和类Unix操作系统的常用命令.它的作用是将参数列表转换成小块分段传递给其他命令,以避免参数列表过长的问题. 例如,下面的命令: rm `find /path -type f` ...
- HDU 1556 Color the ball (数状数组)
Color the ball Time Limit: 9000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)To ...
- Sqlserver大数据量分区表创建
/* 逆向删除对象 DROP PARTITION SCHEME [PS_BasicPolicy2014]; DROP PARTITION FUNCTION [PF_BasicPolicy2014]; ...