poj1936 All in All
程序员文章站
2022-03-13 23:27:32
...
All in All
Time Limit: 1000MS | Memory Limit: 30000K | |
Total Submissions: 26236 | Accepted: 10638 |
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.
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
Source
#include<cstdio> #include<cstring> using namespace std; #define MAXN 100000+5 char s[MAXN],str[MAXN]; int main(){ int i,j,len1,len2; while(~scanf("%s%s",s,str)){ len1=strlen(s); len2=strlen(str); i=j=0; while(i<len2&&j<len1){ if(s[j]==str[i]){ i+=1; j+=1; } else i+=1; } if(j==len1) printf("Yes\n"); else printf("No\n"); } return 0; }
推荐阅读
-
音/视频转换器Tipard All Music Converter安装及激活教程(附激活补丁+软件下载)
-
微软中国上线Surface All Access计划:可享24期免息分期福利
-
5分钟了解MySQL5.7中union all用法的黑科技
-
win2003下PHP使用preg_match_all导致apache崩溃问题的解决方法
-
不再做4G手机的联想能凭借All in 5G重回一线品牌吗?官方这样说
-
delete archivelog all无法清除归档日志解决方法
-
解决Error:All flavors must now belong to a named flavor dimension. Learn more at https://d.android.com
-
python中模块的__all__属性详解
-
sql 中 并集union和union all的使用区别
-
关于angularjs异步操作后台请求时,用$q.all排列先后顺序的问题