BestCoder Round #48 ($) wyh2000 and a string problem
来源:互联网 发布:建行网络学系统网址 编辑:程序博客网 时间:2024/05/28 15:23
wyh2000 and a string problem
Accepts: 417
Submissions: 767
Time Limit: 2000/1000 MS (Java/Others)
Memory Limit: 131072/65536 K (Java/Others)
问题描述
青年理论计算机科学家wyh2000在教小学生一些基础的字符串概念。定义一个字符串s 的子序列为将s 中一些元素删掉得到的字符串。可以删掉全部元素,可以不删,也可以只删一些。他还教了小学生如何判断一个串是不是另一个串的子序列。比如给你一个串,要求判断wyh 是不是它的子序列,那么你只需要找一个w ,找一个y ,再找一个h ,使得w 在y 前面,y 在h 前面即可。有一天小学生拿着一个串问他“wyh 是不是这个串的子序列?”但是wyh2000有重度近视眼,如果字符串中有一段连续的v (至少两个),那么他会把它看成一个w 。例如,字符串vvv 会被看成w ,字符串vvwvvv 会被看成www ,字符串vwvv 会被看成vww 。请问wyh2000会怎么回答这个问题?
输入描述
第一行为数据组数T(1≤T≤105) 。接下来T 行,每行一个字符串,表示小学生拿来问wyh2000的串。总串长不超过3145728。只包含小写字母。hack数据字符串长度不超过100000。
输出描述
对于每组数据,如果wyh2000会把wyh 看成该串的子串,那么输出一行Yes ,否则输出一行No 。
输入样例
4woshiyangliwoyeshiyanglivvuuyehvuvuyeh
输出样例
NoYesYesNo
#include<stdio.h>#include<string.h>int main(){int t,len1,num,j,len2,k;char str1[100001],str2[100001];scanf("%d",&t);while(t--){num=0;j=0;k=0;scanf("%s",str1);len1=strlen(str1);for(int i=0;i<len1;i++){if(str1[i]=='v') num++;else{if(num>=2) str2[j++]='w'; else str2[j++]=str1[i];num=0; } }len2=strlen(str2);for(int i=0;i<len2;i++){if(str2[i]=='w'&&k==0) k=1; if(str2[i]=='y'&&k==1) k=2; if(str2[i]=='h'&&k==2) k=3;} if(k==3) printf("Yes\n"); else printf("No\n");}return 0;}
0 0
- BestCoder Round #48 ($) wyh2000 and a string problem
- HDU-5284-wyh2000 and a string problem(BestCoder Round #48 ($))
- BestCoder Round #48 ($)HDU5284 wyh2000 and a string problem
- HDU 5284 wyh2000 and a string problem——BestCoder Round #48(普通的字符串处理)
- bestcoder 48# wyh2000 and a string problem (水题)
- BestCoder Round #48 ($)HDU5285 wyh2000 and pupil
- wyh2000 and a string problem(模拟)
- HDU 5284 wyh2000 and a string problem
- hdu 5284 wyh2000 and a string problem
- wyh2000 and a string problem(HDU5284)
- HDU - 5284 wyh2000 and a string problem
- wyh2000 and a string problem(bc题)
- HDU 5284 wyh2000 and a string problem(查找字符)
- BestCoder Round #56 Clarke and problem
- BestCoder Round #89 1001 Fxx and string
- 【枚举】HDU5944Fxx and string【BestCoder Round #89】
- hdu 5284 wyh2000 and a string problem(没有算法,只考思维,字符数组得开20万,不然太小了)
- BestCoder Round #11 (Div. 2)--Bob and math problem
- GP基础汇总
- 教你透彻了解红黑树
- 自学Qt_2,第一个应用程序
- JAVA实现快速排序
- UVA 1374 Power Calculus(迭代深搜)
- BestCoder Round #48 ($) wyh2000 and a string problem
- 数组搜索的实现,菜鸟自己写的,没参考任何代码
- [转][编程之美]2.11 寻找最近点对
- nyoj96
- (php)验证码局部刷新
- java线程协作
- 使用ThoughtWorks.QRCode生成二维码
- C++中cin,cin.get,cin.getline()的区别
- [leetcode] 203.Remove Linked List Elements