All in All

Time Limit: 1000MS Memory Limit: 30000K

Total Submissions: 30543 Accepted: 12723

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>
#include <algorithm>
#include <math.h>
#include <stdlib.h> using namespace std;
#define MAX 100000
char a[MAX+5];
char b[MAX+5];
int main()
{
int pos;
bool res;
while(scanf("%s%s",&a,&b)!=EOF)
{
pos=-1;
res=true;
int tag;
int len1=strlen(a);
int len2=strlen(b);
for(int i=0;i<len1;i++)
{
tag=0;
for(int j=0;j<len2;j++)
{
if(a[i]==b[j])
{
if(j>pos)
{
tag=1;
pos=j;
break;
}
}
}
if(tag==0)
res=false;
}
if(res==true)
printf("Yes\n");
else
printf("No\n");
}
}

POJ--1936 All in All(水题,暴力即可)的更多相关文章

  1. poj 1936 All in All(水题)

    题目链接:http://poj.org/problem?id=1936 思路分析:字符串子序列查找问题,设置两个指针,一个指向子序列,另一个指向待查找的序列,查找个字符串一次即可判断.算法时间复杂度O ...

  2. poj 3080 Blue Jeans(水题 暴搜)

    题目:http://poj.org/problem?id=3080 水题,暴搜 #include <iostream> #include<cstdio> #include< ...

  3. POJ 3984 - 迷宫问题 - [BFS水题]

    题目链接:http://poj.org/problem?id=3984 Description 定义一个二维数组: int maze[5][5] = { 0, 1, 0, 0, 0, 0, 1, 0, ...

  4. poj 1007:DNA Sorting(水题,字符串逆序数排序)

    DNA Sorting Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 80832   Accepted: 32533 Des ...

  5. poj 1004:Financial Management(水题,求平均数)

    Financial Management Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 126087   Accepted: ...

  6. POJ 3176 Cow Bowling (水题DP)

    题意:给定一个金字塔,第 i 行有 i 个数,从最上面走下来,只能相邻的层数,问你最大的和. 析:真是水题,学过DP的都会,就不说了. 代码如下: #include <cstdio> #i ...

  7. poj 1658 Eva's Problem(水题)

    一.Description Eva的家庭作业里有很多数列填空练习.填空练习的要求是:已知数列的前四项,填出第五项.因为已经知道这些数列只可能是等差或等比数列,她决定写一个程序来完成这些练习. Inpu ...

  8. POJ 1013 小水题 暴力模拟

    Counterfeit Dollar Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 35774   Accepted: 11 ...

  9. ACM: POJ 1401 Factorial-数论专题-水题

    POJ 1401 Factorial Time Limit:1500MS     Memory Limit:65536KB     64bit IO Format:%lld & %llu   ...

  10. POJ 1986 DIstance Query LCA水题

    给出一棵树,对于每一个询问,给出2个节点,输出2个节点的距离. 输入中有字母,那个是没有用的,不用管. 思路: 0.选择编号为1的节点作为树的root (注意:有些题的边是单向的,这时候我们要根据节点 ...

随机推荐

  1. instsrv.exe srvany.exe启动服务

    1.通过注册表注册服务 private static readonly string regpath = @"SYSTEM\CurrentControlSet\Services\Consul ...

  2. Struts2_day01讲义_使用Struts2完成客户列表显示的功能

  3. 04-vi使用方法详细介绍

    vi使用方法详细介绍 vi编辑器是所有Unix及Linux系统下标准的编辑器,它的强大不逊色于任何最新的文本编辑器,这里只是简单地介绍一下它的用法和一小部分指令.由于对Unix及Linux系统的任何版 ...

  4. 使用librtmp进行H264与AAC直播

    libx264 版本是 128libfaac 版本是 1.28 1.帧的划分 1.1 H.264 帧 对于 H.264 而言每帧的界定符为 00 00 00 01 或者 00 00 01. 比如下面的 ...

  5. zabbix设置报警通知

    邮件通知是最流行的报警通知方式,这里配置邮件通知 1. 配置通知邮箱信息(发件人)的邮箱信息 2. 填写信息 3. 事件(Action)通知配置 点击创建动作 添加一个触发条件 点击添加 添加一个操作 ...

  6. .Net学习心得

      把握自己就是,就是时时拥一颗清澈的心,拥有一片明朗的情怀,缓缓地,从2014的国度里跨进了2015,而我们也就随之告别了2个月的学习之旅,在这里我们拥有了如白色漂渺的梦,黯然升起,在彩色的云霄里飘 ...

  7. RewriteCond和13个mod_rewrite应用举例Apache伪静态

    1.给子域名加www标记 RewriteCond %{HTTP_HOST} ^([a-z.]+)?example\.com$ [NC] RewriteCond %{HTTP_HOST} !^www\. ...

  8. boost::noncopyable介绍

    http://blog.csdn.net/huang_xw/article/details/8248960# boost::noncopyable比较简单, 主要用于单例的情况.通常情况下, 要写一个 ...

  9. Material Design系列第一篇——Creating Apps with Material Design

    Creating Apps with Material Design //创建Material Design的App Material design is a comprehensive guide ...

  10. Ajax技术(WEB无刷新提交数据)

    (转自:http://www.jb51.net/article/291.htm) Ajax内部交流文档一.使用Ajax的主要原因 1.通过适当的Ajax应用达到更好的用户体验: 2.把以前的一些服务器 ...