Title Link: all on all
Problem E
All on all
Input: Standard Input
Output: Standard Output
Time Limit: 2 seconds
Memory Limit: MB
You are devised a new encryption technique which encodes a message by inserting between its characters randomly generated Strings in a clever. Because of pending patent issues we won't discuss in detail how the strings is generated and inserted into the Origina L message. To validate your method, however, it's necessary to write a program that checks if the message was really encoded in the F Inal string.
Given-Strings s and T, you had to decide whether s is a subsequence ofT, i.e. if You can remove characters from T such so the concatenation of the remaining characters iss.
Input specification
The input contains several testcases. Each are specified by and strings s, T of alphanumeric ASCII characters separated by whitespace. Input is terminated by EOF.
Output specification
For each test, the output, if s is a subsequence of T.
Sample Input
Sequence subsequence
Person compression
VERDI Vivavittorioemanuelerediitalia
Casedoesmatter Casedoesmatter
Sample Output
Yes
No
Yes
No
Source:ulm Local Contest
Source
Root:: Competitive programming 3:the New Lower Bound of programming contests (Steven & Felix Halim):: Problem Solvi Ng Paradigms:: Greedy:: Non classical, usually harder
Root:: AOAPC ii:beginning algorithm Contests (Second Edition) (Rujia Liu):: Chapter 3. Arrays and Strings:: Exercises
Root:: AOAPC i:beginning Algorithm Contests--Training Guide (Rujia Liu):: Chapter 1. Algorithm Design:: General Problem Solving Techniques:: Exercises:beginner
Root:: AOAPC i:beginning algorithm Contests (Rujia Liu):: Volume 4. Algorithm Design
Root:: Competitive programming 2:this increases the lower bound of programming contests. Again (Steven & Felix Halim):: Problem Solving Paradigms:: Greedy-standard
Root:: Competitive programming:increasing The Lower Bound of programming contests (Steven & Felix Halim):: Chapter 3. Problem solving Paradigms:: Greedy
Simple string processing, do not say, directly on the code (re many times,, cry). ):
/*************************************************************************> File name:a.cpp> Author:zzuspy > Mail: [email protected] > Created time:2014 December 01 Monday 20:02 23 seconds ********************************************** /#include <cstdio> #include <cstring> #include <iostream> #include < algorithm> #include <cstdlib> #include <cmath> #include <stack> #include <queue> #define LL Long Long#define max3 (a,b,c) max (A,max (b,c)) #define MIN3 (a,b,c) min (a,min (b,c)) using namespace Std;char a[100005], b[ 100005]; The topic didn't say how big, I only open 10005,re to die before!!!! int main () {while (scanf ("%s%s", A, b)!=eof) {int I, J, Lena = Strlen (a), LenB = strlen (b); if (Lena>lenb) {printf ("no\n"); c Ontinue;} for (i = 0, j = 0; b[j]!= ' &&i<lena; j + +) {if (lena-i>lenb-j) break;if (a[i]==b[j]) i++;} if (I==lena) printf ("yes\n"), Else printf ("no\n");} return 0;}
Uva-10340-all in all (String handling!) )