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 subsequence
person compression
VERDI vivaVittorioEmanueleReDiItalia
caseDoesMatter CaseDoesMatter

Sample Output

Yes
No
Yes
No

#include<iostream>
#include<string.h>
using namespace std;
int main(long i,long j)
{
char s[100000],t[100000];
while(cin>>s>>t)
{
long lens=strlen(s);
long lent=strlen(t);
i=0;
j=0;
while(true)
{
if(i==lens)
{
cout<<"YES"<<endl;
break;
}
if(j==lent)
{
cout<<"NO"<<endl;
break;
}
if(s[i]==t[j])
{
i++;
j++;
}
else j++;
}
memset(s,'\0',lens);
memset(t,'\0',lent);
}
return 0;
}

这是一道简单题,只需比较就行了,当s串存在t串中时,输出YES;否则输出NO

简单的字符串比较题 POJ 1936的更多相关文章

  1. 【洛谷1580】yyy loves Easter_Egg I(字符串处理题)

    点此看题面 大致题意: 略.(一道模拟题,自己去看题面吧) 几个字符数组函数 纯粹是一道字符串处理题,就当是学了一下各种与字符数组相关的函数吧! \(gets()\):这个是比较常用的函数,就是读入一 ...

  2. 阿里面试这样问:redis 为什么把简单的字符串设计成 SDS?

    2021开工第一天,就有小伙伴私信我,还给我分享了一道他面阿里的redis题(这家伙绝比已经拿到年终奖了),我看了以后觉得挺有意思,题目很简单,是那种典型的似懂非懂,常常容易被大家忽略的问题.这里整理 ...

  3. Redis的简单动态字符串实现

    Redis 没有直接使用 C 语言传统的字符串表示(以空字符结尾的字符数组,以下简称 C 字符串), 而是自己构建了一种名为简单动态字符串(simple dynamic string,sds)的抽象类 ...

  4. SQL点滴3—一个简单的字符串分割函数

    原文:SQL点滴3-一个简单的字符串分割函数 偶然在电脑里看到以前保存的这个函数,是将一个单独字符串切分成一组字符串,这里分隔符是英文逗号“,”  遇到其他情况只要稍加修改就好了 CREATE FUN ...

  5. Redis数据结构之简单动态字符串SDS

    Redis的底层数据结构非常多,其中包括SDS.ZipList.SkipList.LinkedList.HashTable.Intset等.如果你对Redis的理解还只停留在get.set的水平的话, ...

  6. 小白的Redis学习(一)-SDS简单动态字符串

    本文为读<Redis设计与实现>的记录.该书以Redis2.9讲解Redis相关内容.请注意版本差异. Redis使用C语言实现,他对C语言中的char类型数据进行封装,构建了一种简单动态 ...

  7. redis_简单动态字符串

    在redis中,C字符串(以'\0'结尾的字符数组)只用在一些无需对字符串值进行修改的地方,比如打印日志.其他情况,redis使用SDS - SimpleDynamicString 简单动态字符串,来 ...

  8. redis 系列3 数据结构之简单动态字符串 SDS

    一.  SDS概述 Redis 没有直接使用C语言传统的字符串表示,而是自己构建了一种名为简单动态字符串(simple dynamic string, SDS)的抽象类型,并将SDS用作Redis的默 ...

  9. 图解Redis之数据结构篇——简单动态字符串SDS

    图解Redis之数据结构篇--简单动态字符串SDS 前言     相信用过Redis的人都知道,Redis提供了一个逻辑上的对象系统构建了一个键值对数据库以供客户端用户使用.这个对象系统包括字符串对象 ...

随机推荐

  1. make: *** No rule to make target `out

    按照google的指引,一路很顺,最后make -j5的时候出现:make: *** No rule to make target `dalvik/vm/mterp/out/InterpAsm-x86 ...

  2. WPF_DatePiker控件的禁止输入

    <!--DatePicker没有只读属性,需要修改里面的DatePickerTextbox--!> <DatePicker.Resources> <Style Targe ...

  3. C#获取本机局域网ip和公网ip

    1.获取局域网ip IPAddress ipAddr = Dns.Resolve(Dns.GetHostName()).AddressList[0];//获得当前IP地址 string ip=ipAd ...

  4. 【jsp 防盗链】Referer的简单使用

    在web系统中,盗链的问题时有发生,即复制一个url地址,在另一个地方也能访问. 在jsp中通过request对象可以获取客户请求信息和表单信息,在客户请求头信息中,"Referer&quo ...

  5. POJ 2368 巴什博奕

    题目大意:给出n个按钮,每次最多可以按L个,按下最后一个按钮的人获胜.求使后手必定获胜的L的最小值(L>=2). 题目思路: 巴什博弈:只有一堆n个物品,两个人轮流从这堆物品中取物,规定每次至少 ...

  6. C++调用C#之C++DLL调用C# COM控件

    1. 新建项目 这里我们使用ATL,来接受C# COM控件向外发送的事件. 2. 初始化ATL #include "stdafx.h" CComModule _module; BO ...

  7. cfedu/A/求和

    题目连接 思路: 用数组直接标记2^n,n属于(0~~31);用LL或者INT都可以,不会爆.但是ans要用LL. #include <set> #include <map> ...

  8. python解析XML之ElementTree

    #coding=utf-8 from xml.etree import ElementTree as ET tree=ET.parse('test.xml') root = tree.getroot( ...

  9. 新建aix实例

    http://www.cnblogs.com/kfarvid/archive/2010/12/21/1912553.html   DB2数据库 http://wenku.baidu.com/view/ ...

  10. [转]ubuntu的which、whereis、locate和find命令

     which 只能寻找执行文件 ,并在PATH变量里面寻找. whereis 从linux文件数据库(/var/lib/slocate/slocate.db)寻找,所以有可能找到刚刚删除,或者没有发现 ...