poj 1936 All in all
2011-11-21 23:24
330 查看
All in All
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
Sample Output
Time Limit: 1000MS | Memory Limit: 30000K | |
Total Submissions: 21170 | Accepted: 8374 |
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
#include<iostream> using namespace std; int main() { char s[100001]; char t[100001]; int i,j; int lens,lent; int pos; while(cin>>s && cin>>t) { lens=strlen(s); lent=strlen(t); if(lens>lent) { cout<<"No"<<endl; continue; } pos=-1; for(i=0;i<lens;i++) { for(j=pos+1;j<lent;j++) { if(s[i]==t[j]) { pos=j; break; } } if(j==lent) { cout<<"No"<<endl; break; } } if(i==lens) cout<<"Yes"<<endl; } return 0; }
相关文章推荐
- POJ 1936:全在其中(All in All )
- [POJ1936 All in All]
- Poj 1936 All in All
- POJ 1936 All in All 题解
- POJ 1936 All in All 字符串 水题
- POJ 题目1936 All in All(水题,暴力)
- POJ-1936 All in All(字符串另类解法)
- POJ1936——All in All
- poj 1936 All in All 水题
- POJ 1936 All in All
- poj 1936 All in All
- poj 1936 All in All
- POJ 1936 All in All (模拟)
- POJ 1936 All in All
- poj1936——All in All
- poj 1936 All in All
- POJ 1936 All in All(串)
- poj 1936 all in all
- 【POJ 1936】All in All
- POJ 1936 All in All【暴搜】