二分要删除几个,然后暴力判定。

#include<cstdio>
#include<cstring>
using namespace std;
int a[200010],n,m;
char s1[200010],s2[200010];
bool cant[200010];
bool check(int x)
{
memset(cant,0,sizeof(cant));
for(int i=1;i<=x;++i)
cant[a[i]]=1;
int j=1;
for(int i=1;i<=n;++i)
if((!cant[i]) && s1[i]==s2[j])
{
++j;
if(j>m)
return 1;
}
return 0;
}
int main()
{
// freopen("d.in","r",stdin);
scanf("%s%s",s1+1,s2+1);
n=strlen(s1+1);
m=strlen(s2+1);
for(int i=1;i<=n;++i)
scanf("%d",&a[i]);
int l=0,r=n-1;
while(l<r)
{
int mid=((l+r+1)>>1);
if(check(mid))
l=mid;
else
r=mid-1;
}
printf("%d\n",l);
return 0;
}

【二分答案】Codeforces Round #402 (Div. 2) D. String Game的更多相关文章

  1. Codeforces Round #402 (Div. 2) D. String Game(二分答案水题)

    D. String Game time limit per test 2 seconds memory limit per test 512 megabytes input standard inpu ...

  2. Codeforces Round #402 (Div. 2) D String Game —— 二分法

    D. String Game time limit per test 2 seconds memory limit per test 512 megabytes input standard inpu ...

  3. Codeforces Round #402 (Div. 2) D. String Game

    D. String Game time limit per test 2 seconds memory limit per test 512 megabytes input standard inpu ...

  4. Codeforces Round #402 (Div. 2)

    Codeforces Round #402 (Div. 2) A. 日常沙比提 #include<iostream> #include<cstdio> #include< ...

  5. Codeforces Round #402 (Div. 2) A+B+C+D

    Codeforces Round #402 (Div. 2) A. Pupils Redistribution 模拟大法好.两个数列分别含有n个数x(1<=x<=5) .现在要求交换一些数 ...

  6. Codeforces Round #402 (Div. 2) D题 【字符串二分答案+暴力】

    D. String Game Little Nastya has a hobby, she likes to remove some letters from word, to obtain anot ...

  7. Codeforces Round #402 (Div. 2) A B C sort D二分 (水)

    A. Pupils Redistribution time limit per test 1 second memory limit per test 256 megabytes input stan ...

  8. Codeforces Round #402 (Div. 2) 题解

    Problem A: 题目大意: 给定两个数列\(a,b\),一次操作可以交换分别\(a,b\)数列中的任意一对数.求最少的交换次数使得任意一个数都在两个序列中出现相同的次数. (\(1 \leq a ...

  9. CodeForces Round #402 (Div.2) A-E

    2017.2.26 CF D2 402 这次状态还算能忍吧……一路不紧不慢切了前ABC(不紧不慢已经是在作死了),卡在D,然后跑去看E和F——卧槽怎么还有F,早知道前面做快点了…… F看了看,不会,弃 ...

随机推荐

  1. 线程 condition_variable

    http://www.cnblogs.com/haippy/p/3252041.html 理解wait():当前线程调用 wait() 后将被阻塞(此时当前线程应该获得了锁(mutex).在线程被阻塞 ...

  2. Ubuntu下安装LNMP之nginx的安装

    Nginx 最初是作为一个 Web 服务器创建的,用于解决 C10k 的问题.作为一个 Web 服务器,它可以以惊人的速度为您的数据服务.但 Nginx 不仅仅是一个 Web 服务器,你还可以将其用作 ...

  3. 压缩跟踪Compressive Tracking

    好了,学习了解了稀疏感知的理论知识后,终于可以来学习<Real-Time Compressive Tracking>这个paper介绍的感知跟踪算法了.自己英文水平有限,理解难免出错,还望 ...

  4. 安卓中使用iconfont

    https://www.cnblogs.com/dongweiq/p/5730212.html

  5. codeforces 1060 C

    https://codeforces.com/contest/1060/problem/C 题意:给你一个长度为n的数列a和长度为m的数列b,定义c(i,j)=ai*bj,得到c矩阵,给定值x,求c矩 ...

  6. rman备份与异机恢复

    一.rman备份脚本并为定时任务 #!/bin/bashsource ~/.bash_profileexport LANG=en_USBACKUP_DATE=`date +%d`#RMAN_LOG_F ...

  7. php 计算两个日期的间隔天数

    使用php内部自带函数实现 1.使用DateTime::diff 实现计算 参考阅读>>PHP DateTime::diff() 上代码: <?php $start = " ...

  8. 一些常用的css片段

    1. 单行文字溢出时省略号 .test{ overflow:hidden; text-overflow:ellipsis; white-space:nowrap; } 2. 多行文字溢出时省略号 .t ...

  9. openstack 问题澄清

    1. neutron中plugin与agent是一一对应的吗? 在不使用ml2时,plugin与agent一一对应,如ovs-plugin与ovs-agent:当使用ml2 plugin时,该plug ...

  10. Method and apparatus for providing total and partial store ordering for a memory in multi-processor system

    An improved memory model and implementation is disclosed. The memory model includes a Total Store Or ...