博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
13040:All in All
阅读量:6852 次
发布时间:2019-06-26

本文共 1616 字,大约阅读时间需要 5 分钟。

All in All
Time Limit: 1000MS   Memory Limit: 30000K
Total Submissions: 34909   Accepted: 14571

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

sequence subsequenceperson compressionVERDI vivaVittorioEmanueleReDiItaliacaseDoesMatter CaseDoesMatter

Sample Output

YesNoYesNo

Source

一定要记得每次重置字符串,不然会runtime error!

#include
#include
using namespace std;const int maxn = 100000 + 5;char s[maxn],t[maxn];int main(){ while(scanf("%s %s",s,t) != EOF){ int i = 0; for(int j = 0;t[j];j++){ if(s[i] == t[j]) i++; } if(s[i]) printf("No\n"); else printf("Yes\n"); memset(s,'\0',sizeof(s)); memset(t,'\0',sizeof(t)); } return 0;}

转载于:https://www.cnblogs.com/JingwangLi/p/10202762.html

你可能感兴趣的文章
Ubuntu 外网不通解决方案
查看>>
OSChina 周六乱弹 —— 历史总是惊人的相似
查看>>
MySQL 大小写
查看>>
Lync 2013部署图片赏析-证书服务安装配置
查看>>
HTML5 本地缓存 (web存储)
查看>>
tomcat redis session共享(包含redis安全设置)
查看>>
iptables中DNAT、SNAT和MASQUERADE的作用
查看>>
kvm命令学习记录
查看>>
小菜鸡进阶之路-First week
查看>>
ORACLE 10g SYSAUX表空间快速增长之WRH$_ACTIVE_SESSION_HISTORY篇
查看>>
我的友情链接
查看>>
我的友情链接
查看>>
子数组的和的最大值(包括升级版的首尾相连数组)
查看>>
LeetCode - Nth Highest Salary
查看>>
9.ORM数据访问
查看>>
在RHEL5下搭建SSH远程登录服务器
查看>>
使用Moblin SDK开发应用程序 -- Image Creator
查看>>
【我们都爱Paul Hegarty】斯坦福IOS8公开课个人笔记14 视图绘制Demo
查看>>
/dev/null &
查看>>
在Ubuntu上安装Node.js的Upstream版本
查看>>