UVA - 10340 - All in All (字符串处理!)
2014-12-01 21:07
337 查看
题目链接: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 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 Specification
The input contains several testcases. Each is specified by two strings s, t of alphanumeric ASCII characters separated by whitespace. Input is terminated by EOF.
Output Specification
For each test case output, if s is a subsequence of t.
Sample Input
Sample Output
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
简单字符串处理,不说了,直接上代码(RE好多次,,哭。。):
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 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 Specification
The input contains several testcases. Each is specified by two strings s, t of alphanumeric ASCII characters separated by whitespace. Input is terminated by EOF.
Output Specification
For each test case 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 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
简单字符串处理,不说了,直接上代码(RE好多次,,哭。。):
/************************************************************************* > File Name: a.cpp > Author: zzuspy > Mail: zzuspy@qq.com > Created Time: 2014年12月01日 星期一 20时02分23秒 ************************************************************************/ #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]; //题目没说多大,我之前只开10005,RE到死啊!!!! int main() { while(scanf("%s %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<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 :简单字符串处理
- uva 10340 All in All(字符串处理)
- UVa 10340 All in All (字符串处理&编程技巧)
- UVa 494 Kindergarten Counting Game (字符串处理)
- uva 401 Palindromes(基本的字符串处理)
- uva 11988 Broken Keyboard(字符串处理+ STL)
- uva 185 Roman Numerals (深搜+字符串处理)
- uva 502 DEL command(字符串处理)
- uva 644 Immediate Decodability(字符串处理)
- Palindromes - UVa 401 字符串处理
- uva 10878 Decode the tape(字符串处理)
- Artificial Intelligence? - UVa 537 字符串处理
- uva 401 Palindromes(字符串处理)
- uva - 10340 All in All(字符串、贪心)
- uva:310 - L--system(字符串处理+ bfs)
- UVa 455 Periodic Strings (字符串处理)
- uva 10815 Andy's First Dictionary(字符串处理+sort排序)
- uva 310 L--system(隐式图搜索+字符串处理)
- (字符串的处理4.7.14)UVA 10252 Common Permutation(寻找两个字符串中的共同字符&&按字典序输出)
- Automatic Poetry - UVa 10361 简单字符串处理