HDU - 5284 wyh2000 and a string problem
来源:互联网 发布:淘宝上的蜜蜡是真的吗 编辑:程序博客网 时间:2024/05/14 07:01
Young theoretical computer scientist wyh2000 is teaching young pupils some basic concepts about strings.
A subsequence of a strings s is a string that can be derived from s 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 whetherwyh wyh is a subsequence of some string or not, you just need to find a character w w, a y y, and an h h, so that the w w is in front of the y y, and the y y is in front of the h h.
One day a pupil holding a string asks him, "Iswyh wyh a subsequence of this string?"
However, wyh2000 has severe myopia. If there are two or more consecutive characterv vs, then he would see it as one w w. For example, the string vvv vvv will be seen as w w, the string vvwvvv vvwvvv will be seen as www www, and the string vwvv vwvv will be seen as vww vww.
How would wyh2000 answer this question?Input The first line of the input contains an integer T(T≤105) T(T≤105), denoting the number of testcases.
N 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. OutputYes Yes if wyh2000 would consider wyh wyh as a subsequence of it, or No No otherwise. Sample Input Sample Output
A subsequence of a string
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
One day a pupil holding a string asks him, "Is
However, wyh2000 has severe myopia. If there are two or more consecutive character
How would wyh2000 answer this question?
Total string length will not exceed 3145728. Strings contain only lowercase letters.
The length of hack input must be no more than 100000.
4woshiyangliwoyeshiyanglivvuuyehvuvuyeh
NoYesYesNo
水题 理解题意 按描述处理字符串....
AC代码:
#include <stdio.h>#include <stdlib.h>#include <string.h>#include <math.h>char s[4000005];int main(){ int t,temp[5],i,n; scanf("%d",&t); getchar(); while(t--) { gets(s); n=strlen(s); memset(temp,0,sizeof(temp)); for(i=0;i<n;i++) { if(s[i]=='w'||(s[i]=='v'&&s[i+1]=='v')) { temp[1]++; } else if(s[i]=='y'&&temp[1]!=0) { temp[2]++; } else if(s[i]=='h'&&temp[1]!=0&&temp[2]!=0) { temp[3]++; } if(temp[1]!=0&&temp[2]!=0&&temp[3]!=0) { printf("Yes\n"); break; } } if(temp[1]==0||temp[2]==0||temp[3]==0) { printf("No\n"); } } return 0;}
0 0
- HDU 5284 wyh2000 and a string problem
- hdu 5284 wyh2000 and a string problem
- HDU - 5284 wyh2000 and a string problem
- HDU-5284-wyh2000 and a string problem(BestCoder Round #48 ($))
- HDU 5284 wyh2000 and a string problem(查找字符)
- HDU 5284 wyh2000 and a string problem——BestCoder Round #48(普通的字符串处理)
- wyh2000 and a string problem(模拟)
- wyh2000 and a string problem(HDU5284)
- BestCoder Round #48 ($) wyh2000 and a string problem
- wyh2000 and a string problem(bc题)
- bestcoder 48# wyh2000 and a string problem (水题)
- BestCoder Round #48 ($)HDU5284 wyh2000 and a string problem
- hdu 5284 wyh2000 and a string problem(没有算法,只考思维,字符数组得开20万,不然太小了)
- hdu 5285 wyh2000 and pupil
- HDU 5285 wyh2000 and pupil
- HDU 5285 wyh2000 and pupil
- HDU 5285:wyh2000 and pupil
- hdu 5285 wyh2000 and pupil
- 浅谈Android之Activity 窗口显示流程介绍(一)
- 使用Lombok简化Java代码
- log4j属性文件 每天产生一个日志文件
- JS:正则表达式学习笔记(五) - 量词
- 【前端兼容】2016前端兼容笔记
- HDU - 5284 wyh2000 and a string problem
- 说的好
- 深入源码分析Handler的消息处理机制
- 理解高级指针
- mybatis-编写mapper接口需要遵循一些开发规范
- GIT使用
- <调试记录>system 空间不够大导致的不能开机
- Dubbo-Admin管理平台和Zookeeper注册中心的搭建
- mycat 简单的配置数据库分片(二)