Ultraviolet-10340-All in All (string processing !)
Link: All in All
Problem E
All in All
Input:Standard input
Output:Standard output
Time Limit:2 seconds
Memory Limit:32 MB
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 stringsSAndT, You have to decide whetherSIs a subsequenceT, I. e. if you can remove characters fromTSuch that the concatenation of the remaining characters isS.
Input Specification
The input contains several testcases. Each is specified by two stringsS, tOf alphanumeric ASCII characters separated by whitespace. Input is terminated by EOF.
Output Specification
For each test case output, ifSIs a subsequenceT.
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 Solving 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, not to mention, directly on the Code (RE many times, cry ..) :
/*************************************** * *********************************> File Name: a. cpp> Author: zzuspy> Mail: zzuspy@qq.com> Created Time: monday 1, December 01, 2014 ******************************** **************************************** /# include
# Include
# Include
# Include
# Include
# Include
# Include
# Define LL long # define max3 (a, B, c) max (a, max (B, c) # define min3 (a, B, c) min (, min (B, c) using namespace std; char a [100005], B [100005]; // The question is not too big. I used to open only 10005, RE to death !!!! Int main () {while (scanf ("% s", a, B )! = EOF) {int I, j, lena = strlen (a), lenb = strlen (B); if (lena> lenb) {printf ("No \ n "); continue;} for (I = 0, j = 0; B [j]! = '\ 0' & I
Lenb-j) break; if (a [I] = B [j]) I ++;} if (I = lena) printf ("Yes \ n "); else printf ("No \ n");} return 0 ;}