首页 技术 正文
技术 2022年11月14日
0 收藏 577 点赞 4,737 浏览 1045 个字

Link

题意: 给出两字符串$a$,$b$及一个序列,要求从前往后按照序列删掉$a$上的字符,问最少删多少使$b$串不为a的子串

思路: 限制低,直接二分答案,即二分序列位置,不断check即可。

/** @Date    : 2017-05-07 20:26:33
* @FileName: 779D 二分答案.cpp
* @Platform: Windows
* @Author : Lweleth (SoundEarlf@gmail.com)
* @Link : https://github.com/Lweleth
* @Version : $Id$
*/
#include <bits/stdc++.h>
#define LL long long
#define PII pair
#define MP(x, y) make_pair((x),(y))
#define fi first
#define se second
#define PB(x) push_back((x))
#define MMG(x) memset((x), -1,sizeof(x))
#define MMF(x) memset((x),0,sizeof(x))
#define MMI(x) memset((x), INF, sizeof(x))
using namespace std;const int INF = 0x3f3f3f3f;
const int N = 1e5+20;
const double eps = 1e-8;int p[2*N];
string a, b;
int vis[2*N];int check(int x)
{
int len = a.length();
for(int i = 0; i < len; i++) vis[i] = 0;
for(int i = 0; i < x; i++) vis[p[i] - 1] = 1;int blen = b.length();
int cnt = 0;
for(int i = 0; i < len; i++)
{
if(vis[i])
continue;
if(a[i] == b[cnt])
cnt++;
if(cnt == blen)
return 1;
}
return 0;
}int main()
{
while(cin >> a >> b)
{
int r = a.length();
int l = 1;
for(int i = 0; i < r; i++)
scanf("%d", p + i);
while(l < r)
{
int mid = (l + r) >> 1;
//cout << l << "~" << r << "~" << check(mid) << endl;
if(check(mid))
l = mid + 1;
else r = mid;
}
printf("%d\n", l - 1);
}
return 0;
}
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:8,997
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,511
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,356
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,139
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,770
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,848