神奇(%%题解)

题意:判断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. Day9 - D - Piggy-Bank POJ - 1384

    Before ACM can do anything, a budget must be prepared and the necessary financial support obtained. ...

  2. qrcode在手机上不显示的问题

    可以试试以下解决方案: 1.修改qrcode.min.js:里的function n()红线区域替换成这个 , 原因是这样子才能支持安卓机显示.

  3. python+ selenium + webdriver的环境准备

    web自动化安装 1.安装最新的selenium pip install -U selenium 2.安装chrom浏览器和chromdriver的下载 http://chromedriver.sto ...

  4. 微软重制Windows 1.0系统:祖师爷出山了

    Windows官方推特在7月1日发布了一条很有趣的动态,“向大家介绍全新的Windows 1.0,带MS-DOS.时钟等”.配发的视频回顾了从Windows 1.0/3.1到Windows 10期间, ...

  5. synchronized wait notify 生产者消费者

    1.生产者消费者模型 public class ProducterConsumerTest{ public static void main(String[] args){ System.out.pr ...

  6. JAVA字符串比较问题

    在java中值类型通过==来进行比较值是否相等 而字符串作为一种引用类型,通过==是用来比较其内存位置的,使用equals才是用来比较其值是否相等 使用equals时养成将字符串放在前面的好习惯 字符 ...

  7. Delphi另一个多线程函数:BeginThread用法

    Delphi另一个多线程函数:BeginThread━━━━━━━━━━━━━━━━━━━━━━━━━━ Delphi也提供了一个相同功能的类似函数:function BeginThread(    ...

  8. 使用Indy解决Could not load SSL Library错误

    测试平台:DelphiXE7 + Indy 10.6.0.5169 + Win7 64bit 步骤: 1. SSL下载版本:openssl-1.0.1j-i386-win32 可去http://yun ...

  9. 埃及分数问题 迭代加深搜索/IDA*

    输入整数a,b (0<a<b<500) ,输出最佳表达式 使得加数个数尽量小,如果加数个数相同,则最小的分数越大越好 ,输出表达式 考虑从小到大枚举深度上限maxd,每次执行只考虑深 ...

  10. NO15 第一关课后考试

    第一关课后考试: 1.创建目录/data/oldboy,并且在该目录下创建文件oldboy.txt,然后在文件oldboy.txt里写如内容:inet addr:10.0.0.8 Bcast:10.0 ...