poj1936
来源:互联网 发布:淘宝返利网哪个好用 编辑:程序博客网 时间:2024/05/16 17:31
All in All
Time Limit: 1000MS Memory Limit: 30000KTotal Submissions: 25104 Accepted: 10100
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 subsequenceperson compressionVERDI vivaVittorioEmanueleReDiItaliacaseDoesMatter CaseDoesMatter
Sample Output
YesNoYesNo
Source
Ulm Local 2002
纯粹的LCS 只不过用滚动数组节省空间。
#include <iostream>#include <cstdio>#include <cstring>#define MAX 100001using namespace std;int main(){ char s1[MAX],s2[MAX]; while(~scanf("%s %s",s1,s2)){ int len1 = strlen(s1); int len2 = strlen(s2); int cost[2][MAX]; for(int i=0;i<MAX;i++) { cost[0][i]=0; cost[1][i]=0; } int m = -1; for(int i=1;i<=len1;i++) for(int j=1;j<=len2;j++) { if(s1[i-1]==s2[j-1]) { cost[i%2][j] = cost[(i-1)%2][j-1]+1; m = max(m,cost[i%2][j]); } else cost[i%2][j] = max(cost[(i-1)%2][j],cost[i%2][j-1]); } if(m==len1) printf("Yes\n"); else printf("No\n"); } return 0;}
- poj1936
- poj1936
- poj1936
- poj1936
- poj1936
- poj1936
- poj1936
- poj1936
- poj1936
- POJ1936
- poj1936
- poj1936
- poj1936
- poj1936 水题
- poj1936找子串
- poj1936 All in All
- POJ1936--All in All
- POJ1936:All in All
- asp.net——web.config文件的配置
- 小知识:了解网页浏览器主流四大内核
- 数据库备份还原
- 大学课程思维导图
- 苦逼程序员你中了么?
- poj1936
- 关于开发板的telnetd服务器
- OpenStack监控组件Ceilometer与Folsom结合部署心得
- ADSP 错误 1
- netlink 编程介绍
- 转:Qt Creator的配置和开发初步测试
- Win7家庭版启用Administrator账户
- *** non-numeric second argument to `wordlist' function: ''. Stop.
- 实现Qt日志功能并输出到文件(qDebug\qWarning\ qCritical\qFatal)