【二分答案】Codeforces Round #402 (Div. 2) D. String Game
二分要删除几个,然后暴力判定。
#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的更多相关文章
- 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 ...
- 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 ...
- 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 ...
- Codeforces Round #402 (Div. 2)
Codeforces Round #402 (Div. 2) A. 日常沙比提 #include<iostream> #include<cstdio> #include< ...
- Codeforces Round #402 (Div. 2) A+B+C+D
Codeforces Round #402 (Div. 2) A. Pupils Redistribution 模拟大法好.两个数列分别含有n个数x(1<=x<=5) .现在要求交换一些数 ...
- 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 ...
- 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 ...
- Codeforces Round #402 (Div. 2) 题解
Problem A: 题目大意: 给定两个数列\(a,b\),一次操作可以交换分别\(a,b\)数列中的任意一对数.求最少的交换次数使得任意一个数都在两个序列中出现相同的次数. (\(1 \leq a ...
- CodeForces Round #402 (Div.2) A-E
2017.2.26 CF D2 402 这次状态还算能忍吧……一路不紧不慢切了前ABC(不紧不慢已经是在作死了),卡在D,然后跑去看E和F——卧槽怎么还有F,早知道前面做快点了…… F看了看,不会,弃 ...
随机推荐
- Ubuntu14.04 换源 阿里云
sudo cp /etc/apt/sources.list /etc/apt/sources.list_backup sudo vim /etc/apt/sources.list sudo apt-g ...
- django自己搭建的博客
1.博客地址: http://jiangtao4.pythonanywhere.com/ 2.后台可以发布笔记,可以翻页,数据存在MySQL里面 3.GitHub地址: https://github. ...
- jquery、zepto冲突
<script type="text/javascript" src="js/jquery.min.js"></script> < ...
- 最大流算法 ISAP 模板 和 Dinic模板
ISAP // UVa11248 Frequency Hopping:使用ISAP算法,加优化 // Rujia Liu struct Edge { int from, to, cap, flow; ...
- 标签 JLable 类
标签JLable上可以添加图像,当鼠标停留在标签上时,可以显示一段提示文字. package first; import javax.swing.*; import java.awt.*; impor ...
- vue入门介绍
vue:解决前端大型应用的开发,将之前几十个.几百个.更多的HTML页面集成1个html页面(单页面应用)jquery:前端方法库bootstrap:UI组件库 angular/react这两个框架都 ...
- cobalt strike使用笔记
启动: ./teamserver 192.168.74.1 admin #启动cs服务器.admin为密码. 监听器: windows/beacon_dns/reverse_dns_txtwindow ...
- 正则表达式 re模块 collections模块
根据手机号码一共11位并且是只以13.14.15.18开头的数字这些特点,我们用python写了如下代码: while True: phone_number = input('please input ...
- MySQL MyISAM优化设置点滴
先说一点问题: Mysql中的InnoDB和MyISAM是在使用MySQL中最常用的两个表类型,各有优缺点.两种类型最主要的差别就是 InnoDB 支持事务处理与外键和行级锁.而MyISAM不支持 ...
- 【linux】kill ;杀死某一用户下的所有进程
[linux]kill :杀死某一用户下的所有进程 https://my.oschina.net/u/347414/blog/600854