神奇(%%题解)

题意:判断B串作为A串的子序列,不是不可以把A全部覆盖掉。

这样的话就是判断是不是A[i]最右匹配B的点和最左匹配B的点相交(重合)就好。(不重合的话B自然会空出中间一段,那么肯定不能用B来做A的子序列了)

 #include<bits/stdc++.h>
#define LL long long
#define N 100005
using namespace std;
inline int ra()
{
int x=,f=; char ch=getchar();
while (ch<'' || ch>'') {if (ch=='-') f=-; ch=getchar();}
while (ch>='' && ch<='') {x=x*+ch-''; ch=getchar();}
return x*f;
}
char s[N<<],t[N<<];
int L[N<<],R[N<<],last[N<<];
int main()
{
scanf("%s%s",s,t);
memset(last,-,sizeof(last));
int j=,slen=strlen(s),tlen=strlen(t);
for (int i=; i<slen; i++)
{
L[i]=last[s[i]-'a'];
if (j<tlen && s[i]==t[j])
{
L[i]=j;
j++;
}
last[s[i]-'a']=L[i];
}
memset(last,-,sizeof(last));
j=tlen-;
for (int i=slen-; i>=; i--)
{
R[i]=last[s[i]-'a'];
if (j>= && s[i]==t[j])
{
R[i]=j;
j--;
}
last[s[i]-'a']=R[i];
}
bool ok=;
for (int i=; i<slen; i++)
if (L[i]==- || R[i]==- || L[i]<R[i])
{
ok=;
break;
}
ok?puts("Yes"):puts("No");
return ;
}

cf 223B.Two Strings的更多相关文章

  1. CF Set of Strings

    Set of Strings time limit per test 1 second memory limit per test 256 megabytes input standard input ...

  2. CF Vitaly and Strings

    Vitaly and Strings time limit per test 1 second memory limit per test 256 megabytes input standard i ...

  3. CF 543C Remembering Strings

    https://cn.vjudge.net/problem/CodeForces-543C 题目 You have multiset of n strings of the same length, ...

  4. CF 149E Martian Strings 后缀自动机

    这里给出来一个后缀自动机的题解. 考虑对 $s$ 的正串和反串分别建后缀自动机. 对于正串的每个节点维护 $endpos$ 的最小值. 对于反串的每个节点维护 $endpos$ 的最大值. 这两个东西 ...

  5. CF 452E. Three strings(后缀数组+并查集)

    传送门 解题思路 感觉这种题都是套路之类的??首先把三个串并成一个,中间插入一些奇怪的字符,然后跑遍\(SA\).考虑按照\(height\)分组计算,就是每个\(height\)只在最高位计算一次, ...

  6. cf 762C. Two strings

    因为要删去1个串(读错题),所以就直接二分搞就好了. 需要预处理出2个分别从头到尾,或从尾到头需要多长a串的数组,然后二分删去多长就好了. #include<bits/stdc++.h> ...

  7. CF数据结构练习

    1. CF 438D The Child and Sequence 大意: n元素序列, m个操作: 1,询问区间和. 2,区间对m取模. 3,单点修改 维护最大值, 取模时暴力对所有>m的数取 ...

  8. CF 1083 B. The Fair Nut and Strings

    B. The Fair Nut and Strings 题目链接 题意: 在给定的字符串a和字符串b中找到最多k个字符串,使得不同的前缀字符串的数量最多. 分析:  建出trie树,给定的两个字符串就 ...

  9. CF#358 D. Alyona and Strings DP

    D. Alyona and Strings 题意 给出两个字符串s,t,让找出最长的k个在s,t不相交的公共子串. 思路 看了好几个题解才搞懂. 代码中有注释 代码 #include<bits/ ...

随机推荐

  1. 前端学习笔记系列一:1.export default / export const

    export default 是默认导出 export const 是命名导出 参考:Javascript (ES6), export const vs export default(基本上就是翻译这 ...

  2. 嵊州普及Day3T4

      利内罗女士准备来到意大利进行修行.意大利由 n 个城市和 m 条道路构成,道路是双向的.到达第 i 个城市时,她可以取得该城市的全部信仰,并获得 ai 点能力提升,但因为在一个城市可以取得的信仰有 ...

  3. 网站Webshell大马密码极速暴力爆破工具-cheetah

    Cheetah是一个基于字典的暴力密码webshel​​l工具,运行速度与猎豹猎物一样快. Cheetah的工作原理是能根据自动探测出的web服务设置相关参数一次性提交大量的探测密码进行爆破,爆破效率 ...

  4. Socket传输大文件(发送与接收)

    下载 Client using System; using System.Collections.Generic; using System.Linq; using System.Text; usin ...

  5. html5和html4.0.1的<html>标记的区别

    html5新增了一个 manifest属性,定义了缓存信息. html5中废弃了xmlns属性,这个属性在html转换成xhtml是非常有用的,但是html5中并不需要,因此不用写. 但是如果非要写那 ...

  6. leetcode142 Linked List Cycle II

    """ Given a linked list, return the node where the cycle begins. If there is no cycle ...

  7. SciPy 输入输出

    章节 SciPy 介绍 SciPy 安装 SciPy 基础功能 SciPy 特殊函数 SciPy k均值聚类 SciPy 常量 SciPy fftpack(傅里叶变换) SciPy 积分 SciPy ...

  8. swoole之创建子进程

    一.代码 <?php /** * 进程就是正在运行的程序的一个实例 * 比如,在某个终端中执行一个PHP脚本,可以认为就是开启了一个进程,会有对应的进程id(pid) * * swoole进程与 ...

  9. phpMydmin的GetShell思路

    phpMyadmin简介 phpMyadmin是一个以PHP为基础的MySQL数据库管理工具,使网站管理员可通过Web接口管理数据库 . 信息收集 此部分主要需要收集的是网站物理路径,否则后续无法通过 ...

  10. Day5 - H - Supermarket POJ - 1456

    A supermarket has a set Prod of products on sale. It earns a profit px for each product x∈Prod sold ...