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. 编程实现Windows瞬间关机

    我们先来看看Windows正常的关机流程:①关机指令通知Windows子系统csrss.exe,csrss.exe收到通知后会和Winlogon.exe做一个数据交换,再由Winlogon.exe通知 ...

  2. ASP:GB2312格式文本文件转换成UTF-8格式

    '-------------------------------------------------'函数名称:gb2utf_file'作用:利用AdoDb.Stream对象来把GB2312格式文本文 ...

  3. Guess the Array

    Guess the Array time limit per test 1 second memory limit per test 256 megabytes input standard inpu ...

  4. css 重新学习系列(2)

    摘自: http://www.cnblogs.com/liuzhaoyang/articles/3289456.html Position定位:relative | absolute 定位一直是WEB ...

  5. postgresql 在linux上的源码安装

    http://my.oschina.net/hippora/blog/375292 下载源码并解压 [root@fnddb ~]# wget https://ftp.postgresql.org/pu ...

  6. CentOS minimal 版安装图形界面及中文语言

    1.连接网络: CentOS minimal.iso安装好后, 进入终端,默认是不开网络的, 首先启用网卡, 自动获取ip. ifconfig eth0 up dhclient eth0 再 ifco ...

  7. 线程访问 DevExpress控件异常时 解决方法

    Control.CheckForIllegalCrossThreadCalls = false; DevExpress.Data.CurrencyDataController.DisableThrea ...

  8. 《CSS设计指南》阅读笔记

    一.HTML实体 HTML实体常用于生成那些键盘上没有的印刷字符.以一个和号(&)开头,一个分号(:)结尾,二者之间是表示实体的字符串. 如:“左引号(")     ”右引号(&qu ...

  9. hdu_5616_Jam's balance(暴力枚举子集||母函数)

    题目连接:hdu_5616_Jam's balance 题意: 给你一些砝码,和一些要被称出的重量,如果这些砝码能称出来输出YES,否则输出NO 题解:我们想想,这题求组合方式,我们这里可以直接用母函 ...

  10. ng-bind-html在ng-repeat中问题的解决办法

    <div ng-controller="MyCtrl"> Hello, {{name}}! <div class="row" ng-repea ...