POJ 1936 All in All

简介: DescriptionYou have devised a new encryption technique which encodes a message by inserting between its characters randomly generated strings in a clever way.

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
题目要求就是在s2中找字串s1!

#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
using namespace std;
char a[100005],b[100005];
int main()
{
    while(~scanf("%s",a)){
        scanf("%s",b);
        int a_length = strlen(a);
        int b_length = strlen(b);
        int a1,b1=0;
        int i;
        for(i=0;i<a_length;i++){
                bool flag=false;
            for(int j=b1;j<b_length;j++){
                if(a[i]==b[j]){
                    b1=j+1;
                    flag=true;
                    break;
                }
            }
            if(!flag)
                break;
        }
        if(i==a_length)
            printf("Yes\n");
        else
            printf("No\n");
    }
    return 0;
}
目录
相关文章
|
6月前
|
前端开发 JavaScript API
如何快速学习React?
如何快速学习React?
167 1
|
存储 SQL OLAP
分析性能提升40%,阿里云Hologres流量场景最佳实践
分析性能提升40%,阿里云Hologres流量场景最佳实践
|
运维 API Apache
《Saltstack:自动化运维的瑞士军刀,让IT管理变得简单而强大》
【8月更文挑战第13天】面对服务器数量激增和网络复杂化,传统手动运维已难以应对。自动化运维工具Saltstack(简称Salt),基于Python开源,采用C/S架构,由Master和Minion构成,实现任务分发与执行。Salt具备配置管理、远程执行及云管理等功能。通过声明式状态文件,可确保系统符合预期配置;远程执行简化批量任务处理;集成云服务API实现资源动态管理。Salt以高效灵活的方式助力IT基础设施管理,成为现代运维不可或缺的利器。
274 1
|
存储 缓存 算法
《Go 简易速速上手小册》第1章:Go 语言基础(2024 最新版)(下)
《Go 简易速速上手小册》第1章:Go 语言基础(2024 最新版)(下)
100 1
|
存储 关系型数据库 数据库
目前数据库分类
目前数据库分类。
82 3
|
人工智能 移动开发 算法
GRASP优化算法原理梳理和应用细节
GRASP优化算法原理梳理和应用细节
GRASP优化算法原理梳理和应用细节
|
Prometheus Kubernetes 监控
Prometheus Operator(上)
Prometheus Operator(上)
481 0
|
安全 Unix Linux
解决Docker必须使用sudo操作的问题
解决Docker必须使用sudo操作的问题
814 0
|
Go 开发者
Go语言代码优雅之道:简洁、清晰示例驱动
Go语言代码优雅之道:简洁、清晰示例驱动
267 0
|
运维 监控 小程序
淘宝小游戏背后的质量保障方案
2022年4月,淘宝开启了小程序游戏项目,旨在从互动公域和店铺私域引入了大量的三方游戏服务商入淘 ,初步构建淘宝游戏的三方生态。对于开放质量团队来说,“游戏生态管控 & 游戏容器测试”是一个新的命题。
1204 1
淘宝小游戏背后的质量保障方案