All in All(POJ--1936
2015-08-11 09:47
323 查看
Description
You have devised a new encryption technique which encodes a message by inserting between its characters randomly generated strings in
a clever way. Because of pending patent issues we will not discuss in detail how the strings are generated and inserted into the original message. To validate your method, however, it is necessary to write a program that checks if the message is really encoded
in the final string.
Given two strings s and t, you have to decide whether s is a subsequence of t, i.e. if you can remove characters from t such that the concatenation of the remaining characters is s.
Input
The input contains several testcases. Each is specified by two strings s, t of alphanumeric ASCII characters separated by whitespace.The
length of s and t will no more than 100000.
Output
For each test case output "Yes", if s is a subsequence of t,otherwise output "No".
题意:输入两个字符串s和t,判断s是不是t的子串。
思路:模拟比较两个字符串。
Sample Input
Sample Output
You have devised a new encryption technique which encodes a message by inserting between its characters randomly generated strings in
a clever way. Because of pending patent issues we will not discuss in detail how the strings are generated and inserted into the original message. To validate your method, however, it is necessary to write a program that checks if the message is really encoded
in the final string.
Given two strings s and t, you have to decide whether s is a subsequence of t, i.e. if you can remove characters from t such that the concatenation of the remaining characters is s.
Input
The input contains several testcases. Each is specified by two strings s, t of alphanumeric ASCII characters separated by whitespace.The
length of s and t will no more than 100000.
Output
For each test case output "Yes", if s is a subsequence of t,otherwise output "No".
题意:输入两个字符串s和t,判断s是不是t的子串。
思路:模拟比较两个字符串。
Sample Input
sequence subsequence person compression VERDI vivaVittorioEmanueleReDiItalia caseDoesMatter CaseDoesMatter
Sample Output
Yes No Yes No
#include <cstdio> #include <queue> #include <cstring> #define MAX 100002 using namespace std; char s[100002],t[100002]; int main() { //freopen("oo.text","r",stdin); while(~scanf("%s %s",s,t)) { int len1,len2,flag,cnt=0,i=0,j=0; len1=strlen(s); len2=strlen(t); while(1) { if(s[i]==t[j]) { cnt++; i++; j++; } else j++; if(cnt==len1) { flag=1; break; } if(j==len2) { flag=0; break; } } if(flag) printf("Yes\n"); else printf("No\n"); } return 0; }<strong> </strong>
相关文章推荐
- 生如夏花之绚烂,Lisp风格的liang语言诞生了!
- BZOJ3543: [ONTAK2010]Garden
- Tomcat的管道(Pipeline)机制以及Context,Wrapper容器
- Big Big World-Emilia
- c++迭代器失效2
- 17-集合框架-23-常用对象API(集合框架-TreeSet集合-Comparator比较器)
- JavaFx lineChart real-time Monitor
- Eclipse 在编辑窗口显示打印边距(换行参考线)
- C++基础知识实例解析(一)
- PHP和Mysql的Timestamp互换
- 浅谈尾递归和goto循环
- javascript实现数组中的内容随机输出
- JSTL中fn表达式的使用说明
- hdoj 1233 还是畅通工程 【最小生成树】
- SVN目录结构详解
- myeclipse反向机制生成javabean
- Android 实例:多线程下载,进度条,音乐播放器
- 畅通工程 HDU杭电1863【克鲁斯卡尔Kruskal || Prim】
- 黑马程序员—————Java基础语法(1)----关键字、标示符、注释、常量、进制、变量、运算符
- Hdu 1863 畅通工程【最小生成树】