J - All in All UVA - 10340
2017-07-21 19:06
323 查看
You have devised a new encryption technique which encodes a message by inserting between its charactersrandomly generated strings in a clever way. Because of pending patent issues we will not discuss indetail 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 finalstring.Given two strings s and t, you have to decide whether s is a subsequence of t, i.e. if you can removecharacters
from t such that the concatenation of the remaining characters is s.InputThe input contains several testcases. Each is specified by two strings s, t of alphanumeric ASCIIcharacters separated by whitespace. Input is terminated by EOF.OutputFor each test case
output, if s is a subsequence of t.Sample Inputsequence subsequenceperson compressionVERDI vivaVittorioEmanueleReDiItaliacaseDoesMatter CaseDoesMatterSample OutputYesNoYesNo
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 finalstring.Given two strings s and t, you have to decide whether s is a subsequence of t, i.e. if you can removecharacters
from t such that the concatenation of the remaining characters is s.InputThe input contains several testcases. Each is specified by two strings s, t of alphanumeric ASCIIcharacters separated by whitespace. Input is terminated by EOF.OutputFor each test case
output, if s is a subsequence of t.Sample Inputsequence subsequenceperson compressionVERDI vivaVittorioEmanueleReDiItaliacaseDoesMatter CaseDoesMatterSample OutputYesNoYesNo
#include <iostream> #include<cstdio> #include<cstring> #include<string.h> #include<string> #include<stdio.h> #include<algorithm> using namespace std; int main() { char s1[1000001]; char s2[1000001]; int i,j; while(scanf("%s%s",s1,s2)!=EOF) { int l=strlen(s1); j=l-1; for(i=strlen(s2)-1; i>=0; i--) { if(s2[i]==s1[j]) j--; } if(j==-1) printf("Yes\n"); else printf("No\n"); } return 0; }
相关文章推荐
- UVA 10340 All in All
- 子序列(All in All, UVa 10340)
- uva 10340 All in All(子串)
- [UVA]10340 All in All
- 子序列-All in All,UVa10340
- UVA - 10340 All in All
- uva 10340-all in all
- Uva - 10340 - All in All
- UVA - 10340 All in All
- UVa 10340 All in All
- UVA 10340 - All in All
- UVA All in All 10340
- UVA 10340 All in All
- UVa 10340:All in All(字符串)
- Uva 10340 All in All
- UVA - 10340 All in All
- All in All UVA - 10340
- Uva - 10340 - All in All
- 习题3-9 子序列(All in All, UVa 10340)
- uva 10340 All in All