Poj 1936 All in All
2015-08-10 10:05
351 查看
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: 29727 | Accepted: 12369 |
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 纯水题。。。(脑子里有杂念>_<!,害的我弄了半小时,来首歌放弃一切~~,进正题)。 在输入的时候注意先用gets()输入整题,然后划分。#include<iostream> #include<cstring> #include<cstdio> using namespace std; char a[100010],b[100010],tmp[200010]; int l1,l2,z1,z2; int main() { int i,n,j,m,bj,k; while(gets(tmp)!=NULL) { z1=z2=0; int bj=0; for(i=0;tmp[i]!='\0';i++) { if(tmp[i]!=' '&&!bj) { a[z1++]=tmp[i]; } else if(bj) { b[z2++]=tmp[i]; } else if(tmp[i]==' ') { bj=1; } } m=strlen(tmp); a[z1]='\0'; b[z2]='\0'; //cout<<m<<" "<<z1<<" "<<z2<<endl; bj=0; i=0; for(j=0;j<z2;j++) { // while(a[i]!='\0') // { if(a[i]==b[j]) { i++; } if(a[i]=='\0') { bj=1; break; } // else // i=0; //} } if(bj) puts("Yes"); else puts("No"); } }
相关文章推荐
- 最小二乘法拟合直线 C++/OpenCV
- 服务设计的原则:服务模式与反模式
- 浅谈web应用的负载均衡、集群、高可用(HA)解决方案
- 你也可以有自己的天气预报啦!
- 第一个bootstrap网页
- 屏幕适配
- 计蒜客 难题题库 201 奖学金的分配
- HDU 3308 LCIS(线段树区间合并 单点更新)
- 批量重读PP主数据 BDC
- 平衡二叉树的C语言实现(创建、插入、查找、删除、旋转)【数据结构】
- 2.1 数据结构-属性方法
- watchOS 2:动画的力量
- 电脑常见故障处理办法I
- opscenter dashboard排错
- opscenter dashboard排错
- opscenter dashboard排错
- AttributeError: 'module' object has no attribute 的解决方法
- 天声人語 20150810
- 【小熊刷题】reverse words in a string w. or w/o. allocating extra space
- hdu 1045 Fire Net (二分匹配)