POJ 1936 All in All(串)

All in All

Time Limit: 1000MS Memory Limit: 30000K
Total Submissions: 27537 Accepted: 11274

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

sequence subsequence
person compression
VERDI vivaVittorioEmanueleReDiItalia
caseDoesMatter CaseDoesMatter

Sample Output

Yes
No
Yes
No

Source

Ulm Local 2002

水一个。

。。

就是推断字符串st1是不是字符串st2的字串。

#include <iostream>
using namespace std;
int main()
{
	char st1[100000],st2[100000];
    __int64 l1,l2,i,j;
	while(cin>>st1>>st2)
	{   i=0;j=0;
		l1=strlen(st1);
		l2=strlen(st2);
		while(1)
		{
			if(i==l1)
			{
				printf("Yes\n");
				break;
			}
			if(i<l1&&j==l2)
			{
				printf("No\n");
				break;
			}
			if(st1[i]==st2[j])
			{
				i++;j++;
			}
			else
				j++;
		}
	}
	return 0;
}
时间: 2024-10-13 14:04:00

POJ 1936 All in All(串)的相关文章

[ACM] POJ 1936 All in All (查找,一个串是否在另一个串中)

All in All Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 27521   Accepted: 11266 Description You have devised a new encryption technique which encodes a message by inserting between its characters randomly generated strings in a clever

POJ 3461 Oulipo (求模式串在文本串中出现的次数)

Oulipo Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 36128   Accepted: 14584 Description The French author Georges Perec (1936–1982) once wrote a book, La disparition, without the letter 'e'. He was a member of the Oulipo group. A quot

POJ 1936 All in All 题解

寻找一个串是否是另外一个字符串的子串序列. 可以想象主串是一连发子弹,而需要查找的子串是一队敌人,然后主串的字符是目标,把主串的所有子弹打完,是否能把子串的所有敌人消灭掉. 很简单的题目. #include <stdio.h> const int MAX_N = 100001; char seq[MAX_N], subSeq[MAX_N]; int main() { while (~scanf("%s %s", subSeq, seq)) { char *s = seq,

POJ 1936.All in All

All in All Time Limit:1000MS     Memory Limit:30000KB     64bit IO Format:%I64d & %I64u Submit Status Practice POJ 1936 Description You have devised a new encryption technique which encodes a message by inserting between its characters randomly gener

POJ 1035 Spell checker (串)

题目大意: 问你后面输入的串能不能通过  加减一个字符,或者替换一个字符变成字典中的串. 思路分析: 直接模拟替换加减的过程. 比较两个串的长度.要相差为1 的时候才能进行模拟. 模拟的过程就是进行一个个的匹配. 发现失配的次数小于等于 1就可以输出. #include <cstdio> #include <iostream> #include <cstring> #include <algorithm> #include <string> #i

POJ 1936 All in All 匹配, 水题 难度:0

题目 http://poj.org/problem?id=1936 题意 多组数据,每组数据有两个字符串A,B,求A是否是B的子串.(注意是子串,也就是不必在B中连续) 思路 设置计数器cnt为当前已匹配A的长度,明显在扫描B的过程中只需要记住cnt这一个状态. 扫描B,每次与A[cnt]匹配就将计数器增加1,cnt与A的长度一致时A就是B的子串. 感想 这道题也许可以用更复杂的方法. 代码 1 #include <cstdio> 2 #include <cstring> 3 #i

POJ 1159-Palindrome(dp_回文串+滚动数组)

Palindrome Time Limit:3000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Submit Status Description A palindrome is a symmetrical string, that is, a string read identically from left to right as well as from right to left. You are to wr

poj 1159 Palindrome -- 回文串,动态规划

Palindrome Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 59029   Accepted: 20505 Description A palindrome is a symmetrical string, that is, a string read identically from left to right as well as from right to left. You are to write a

POJ 3349-Snowflake Snow Snowflakes-字符串哈希

哈希后,对每片雪花对比6次. 1 #include <cstdio> 2 #include <cstring> 3 #include <vector> 4 #include <iostream> 5 #include <algorithm> 6 7 using namespace std; 8 9 const int maxn = 15010; 10 const int prime = 14997; 11 12 struct flake 13 {