UVa 10340 All in All(子序列)
来源:互联网 发布:javascript dom教程 编辑:程序博客网 时间:2024/05/31 20:51
Description
All in All
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 Specification
The input contains several testcases. Each is specified by two strings s, t of alphanumeric ASCII characters separated by whitespace. Input is terminated by EOF.
Output Specification
For each test case output, if s is a subsequence of t.
Sample Input
sequence subsequence
person compression
VERDI vivaVittorioEmanueleReDiItalia
caseDoesMatter CaseDoesMatter
Sample Output
Yes
No
Yes
No
Source: ULM Local Contest
这是我这个专题最先A的一个,大水题无疑。。。但还是WA了一次。。。不对,是RE了,因为数组开小了(但是题上真心没给范围啊)= =
一看示例,这就是一个大小写敏感的子序列的问题啊,果断手敲代码完成,上代码:
#include <iostream>#include <cstring>using namespace std;bool isSubString(char sub[],char str[]); //用于判断两个参数前者是否为后者的子序列int main(){char str[111111];//就这俩数组,开大点不花钱 = =char sub[111111];while(cin>>sub>>str){if(isSubString(sub,str))cout<<"Yes"<<endl;elsecout<<"No"<<endl;}return 0;}bool isSubString(char sub[],char str[]){int n,i;char *p;//用游动指针来限定可搜寻的起始位置n=strlen(sub);for(i=0,p=str;i<n;i++,p++)if(!(p=strchr(p,sub[i])))//只要sub串中有一个字符在p(str的限定)中未搜寻到,strchr()为NULL,则返回falsereturn false;return true;//如果能循环到底说明在str串中能够搜寻到sub的所有字符,返回true}
- 子序列(All in All, UVa 10340)
- UVa 10340 All in All(子序列)
- UVA 10340 All in All 子序列判定 贪心
- UVa - 10340 - All in All(暴力遍历、子序列)
- 算法竞赛入门-习题3-9 子序列(All in All, UVa 10340)
- 习题3-9 子序列(All in All, UVa 10340)
- POJ1936-All-in-All(子序列)
- uva 10340 All in All(子串)
- uva 10340 All in All(子串)
- 子序列(All in All)
- 小紫书 习题 3-9(UVA 10340)子序列(All in All)
- 习题 3 -9 子序列(All in All) UVa 10304
- 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
- HDOJ 折线分割平面 2050
- texlive2014 texmaker安装过程
- 二叉树的后序遍历
- readelf命令的使用
- 抽象类学习笔记
- UVa 10340 All in All(子序列)
- csu Problem B: String and Arrays
- TzSU 2mFiP愛迪達 GX86 skB
- C++11新特性(六)bind,function,lambda简单使用
- StringBuffer与StringBuilder区别
- POJ1011
- sql子查询
- linux 性能测试工具Lmbench 使用方法
- 安卓面试必问二安卓内存优化OR OOM 内存溢出