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

#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. Mybatis LIKE模糊查询

    1.在代码中拼接好字符串后传入进来 2.使用CONCAT在xml中拼接字符串: <if test="queryParam.keyword != null"> AND b ...

  2. Why is the ibdata1 file continuously growing in MySQL?

    We receive this question about the ibdata1 file in MySQL very often in Percona Support. The panic st ...

  3. selenium 获取某个元素的html

    <table> <tbody id="tb-37327761306"> <tr class="sep-row"><td ...

  4. (转)用python实现抓取网页、模拟登陆

    涉及一系列内容,部分已在前面转载,仍转自crifan: http://www.crifan.com/how_to_use_some_language_python_csharp_to_implemen ...

  5. react 记录:运行npm run eject命令暴露配置文件都报这个错误

    问题: react 使用create-react-app命令创建一个项目,运行npm run eject命令暴露配置文件都报这个错误 原因:主要是脚手架添加 .gitgnore文件,但是却没有本地仓库 ...

  6. js如何弹出新窗口

    js如何弹出新窗口 时间:2012-4-22 弹出新窗口也是在网页设计中会经常用到的,其用法也很简单,是通过调用javascript的内置函数windows.open来产生的.  window.ope ...

  7. 【数据结构】bzoj2957楼房重建

    Description 小A的楼房外有一大片施工工地,工地上有N栋待建的楼房.每天,这片工地上的房子拆了又建.建了又拆.他经常无聊地看着窗外发呆,数自己能够看到多少栋房子. 为了简化问题,我们考虑这些 ...

  8. SVG布局

    http://www.w3cplus.com/html5/nesting-svgs.html

  9. 应对ubuntu linux图形界面卡住的方法

    有的时候,我的ubuntu图形界面会卡住,当然这个时候你可以重新启动,不过最好的办法应该是结束这个桌面进程 那桌面卡住了怎么来结束桌面进程呢? 这时候就需要打开tty了 按下键盘ctrl+alt+f1 ...

  10. Linux中短横线(-)小记

    在Linux中短横线(-)可以表示输出流,具体用法如下. 搭配cat cat - 如果指定cat的文件为-,表示从标准输入读取(和直接使用cat,好像没什么区别) 搭配| echo 123 | cat ...