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. 【scala】scala 数组 (三)

    基础内容 1. 数组定义 定长.可变数组的定义;元素添加,删除,排序,求和等常用运算 import scala.collection.mutable.ArrayBuffer import scala. ...

  2. 搭建项目Maven+springMVC+hibernate时,JUnit測试出现报ClassNotFoundException错误的解决

    近期在搭建Maven+springMVC+hibernate项目,正常启动项目时一切正常.但JUNIT測试时出现报ClassNotFoundException错误,经过细致排查发现没有生成class文 ...

  3. @ControllerAdvice -- 处理异常示例

    Class : SessionInterceptor package com.estate.web.filter; import javax.annotation.Resource; import j ...

  4. Go面向对象(三)

    go语言中的大多数类型都是值予以,并且都可以包含对应的操作方法,在需要的时候你可以给任意类型增加新方法.二在实现某个接口时,无需从该接口集成,只需要实现该接口要求的所有方法即可.任何类型都可以被any ...

  5. flexbox父盒子flex-direction属性

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  6. cocos2d-x 弹出对话框

    登陆界面有一点注册按钮,点击之后弹出一个框,让用户输入一些信息; 在网上找的一些方法都是派生一个类,然后自己实现; 我觉得太麻烦了. 我使用分层的方式来显示, 启动界面就一个,背景图片加几个按钮:登陆 ...

  7. CouchDB 未授权访问漏洞

    0x00 CouchDB安装 CouchDB官方网站:http://couchdb.apache.org/ 一路Next直到完成安装,打开浏览器并访问以下链接:http://127.0.0.1:598 ...

  8. 【RF库Collections测试】Sort List

    Name:Sort ListSource:Collections <test library>Arguments:[ list_ ]Sorts the given list in plac ...

  9. CentOS7--Firewalld防火墙

    Firewalld服务是红帽RHEL7系统中默认的防火墙管理工具,特点是拥有运行时配置与永久配置选项且能够支持动态更新以及"zone"的区域功能概念,使用图形化工具firewall ...

  10. Linux centos 下 eclipse 打开文件时关闭

    原文地址:http://processors.wiki.ti.com/index.php/Linux_Host_Support#cairo-misc.c:380:_cairo_operator_bou ...