`
空城旧梦why
  • 浏览: 25370 次
  • 性别: Icon_minigender_1
  • 来自: 长沙
社区版块
存档分类
最新评论

poj1936 All in All

    博客分类:
  • acm
 
阅读更多
All in All
Time Limit: 1000MS   Memory Limit: 30000K
Total Submissions: 26236   Accepted: 10638

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

 
#include<cstdio>
#include<cstring>
using namespace std;

#define MAXN 100000+5
char s[MAXN],str[MAXN];

int main(){
	int i,j,len1,len2;
	while(~scanf("%s%s",s,str)){
		len1=strlen(s);
		len2=strlen(str);
		i=j=0;
		while(i<len2&&j<len1){
			if(s[j]==str[i]){
				i+=1;
				j+=1;
			}
			else
				i+=1;
		}
		if(j==len1)
			printf("Yes\n");
		else
			printf("No\n");
	}
	return 0;
}
分享到:
评论

相关推荐

    POJ1936-All in All

    【标题】"POJ1936-All in All" 是北京大学在线判题系统POJ(Problem Online Judge)上的一道编程题目。这道题目主要考察的是算法设计和实现能力,通常在这样的在线判题系统中,程序员需要根据题目描述编写程序,解决...

    poj 百练 题目分类

    在 POJ 百练 题目分类中,字符串处理类题目包括统计字符数(2742)、487-3279(2974)、子串(2744)、最难的问题(2975)、字符串判等(2743)、All in All(2976)、W 密码(2819)、古代密码(2820)、词典(2804...

    poj 1007 DNA Sorting

    All the strings are of the same length. Input The first line contains two integers: a positive integer n (0 ) giving the length of the strings; and a positive integer m (0 ) giving the number of ...

    poj图论题目汇总

    在本篇文章中,我们将深入探讨POJ平台上的一系列经典图论问题,并根据提供的部分内容,总结出每个题目背后所涉及的核心算法和技术点。这些题目不仅考验了参赛者的逻辑思维能力,同时也对数据结构和算法的掌握提出了...

    ACM POJ PKU 最全题目分类

    ### ACM POJ PKU 最全题目分类解析 #### 动态规划(DP) 在计算机科学领域,动态规划(Dynamic Programming, DP)是一种重要的算法思想,主要用于解决多阶段决策过程中的优化问题。它通过将原问题分解成相互重叠的...

    POJ 1727 Advanced Causal Measurements (ACM)解题报告

    In summary, solving this problem involves understanding the concept of causality in theoretical physics, implementing a binary search algorithm, and effectively sorting the observed events. The ...

    poj 1006 Biorhythms 生理周期

    We would like to determine when a triple peak occurs (the peaks of all three cycles occur in the same day) for any person. For each cycle, you will be given the number of days from the beginning of ...

    Halloween_TheNeighbours_POJ3370_

    To avoid conflicts the children have decided they will put all sweets together and then divide them evenly among themselves. From last year's experience of Halloween they know how many sweets they ...

    poj 1005 I Think I Need a Houseboat

    I Think I Need a Houseboat Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 41126 Accepted: 16537 Description ...3.All locations are given in miles. Source Mid-Atlantic 2001

    contests-all-in-one:BZOJ,POJ,LeetCode,USACO,HDUOJ,LA的比赛解决方案

    BZOJ,POJ,LeetCode,USACO,HDUOJ,LA的比赛解决方案 有话要说 嗨,我是Ex10si0n。 该存储库用于记录我的OJ AC代码。 关于我 OIer,Develpoer。 希望这个仓库可以帮助那些通过Probelm ID找到LeetCode或其他OJ解决...

    北大ACM题库及解答之四

    题目来源:POJ 1031 解法或类型: 计算几何 作者:杨清玄 Fence Time Limit:1S Memory Limit:1000K Total Submit:103 Accepted:26 Description There is an area bounded by a fence on some flat field. The fence...

    北大ACM试题库及解答之三

    题目来源:POJ 1031 解法或类型: 计算几何 作者:杨清玄 Fence Time Limit:1S Memory Limit:1000K Total Submit:103 Accepted:26 Description There is an area bounded by a fence on some flat field. The fence...

    北大ACM题库及解答打包下载

    题目来源:POJ 1031 解法或类型: 计算几何 作者:杨清玄 Fence Time Limit:1S Memory Limit:1000K Total Submit:103 Accepted:26 Description There is an area bounded by a fence on some flat field. The fence...

    北大ACM试题库及解答打包之二

    题目来源:POJ 1031 解法或类型: 计算几何 作者:杨清玄 Fence Time Limit:1S Memory Limit:1000K Total Submit:103 Accepted:26 Description There is an area bounded by a fence on some flat field. The fence...

    北大ACM试题库及解答之二

    题目来源:POJ 1031 解法或类型: 计算几何 作者:杨清玄 Fence Time Limit:1S Memory Limit:1000K Total Submit:103 Accepted:26 Description There is an area bounded by a fence on some flat field. The fence...

Global site tag (gtag.js) - Google Analytics