POJ 1936 :All in All:简单字符串查找
2014-09-19 20:33
441 查看
All in All
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".
Sample Input
Sample Output
Source
Ulm Local 2002
巨水的题目,一次遍历看一下这个字符串是否蕴含在母串中。连代码量都没有。
Time Limit: 1000MS | Memory Limit: 30000K | |
Total Submissions: 28138 | Accepted: 11591 |
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".
Sample Input
sequence subsequence person compression VERDI vivaVittorioEmanueleReDiItalia caseDoesMatter CaseDoesMatter
Sample Output
Yes No Yes No
Source
Ulm Local 2002
巨水的题目,一次遍历看一下这个字符串是否蕴含在母串中。连代码量都没有。
#include<stdio.h> #include<stdlib.h> #include<string.h> char s[100005],t[100005]; int find() { int i,j; int index,p; p=index=i=j=0; while(i<strlen(s)&&j<strlen(t)) { p=0; for(j=index;j<strlen(t);j++) if(t[j]==s[i]) { if(i==strlen(s)-1) return 1; i++; index=j+1; p=1; break; } if(!p) break; } return 0; } int main() { int i,j; while(scanf("%s%s",s,t)!=EOF) { if(find()) printf("Yes\n"); else printf("No\n"); } return 0; }
相关文章推荐
- POJ 1936 All in All(简单的字符串的字符列)
- poj_1936 All in All(简单字符串)
- poj 1936 All in All (字符串处理)
- POJ-1936 All in All(字符串另类解法)
- [ACM] POJ 1936 All in All (查找,一个串是否在另一个串中)
- (Relax ST1.9)POJ 1936 All in All(判断一个字符串去掉一部分以后是否等价于另一个字符串)
- POJ 1936 All in All 字符串 水题
- All in All--POJ 1936
- POJ1936-All in All
- poj 1936 All in all
- [POJ1936 All in All]
- POJ-1936-All in All
- POJ 1936 All in All
- poj 1936 All in All
- poj 1936 "all in all"
- POJ 1936 All in All
- zoj 1970 || poj 1936 All in All(水题,想说爱你不容易 = =)
- poj 1396 All in All【字符串】
- poj 1936 All in All 水题
- poj 1936 all in all