当前位置: 首页 > news >正文

做音箱木工网站互联网营销师培训机构哪家好

做音箱木工网站,互联网营销师培训机构哪家好,小广告内容,自己做网站难文章目录 CF778A String Game 题解题面翻译Input DataOutput DataInput Sample 1Output Sample 1题目描述输入格式输出格式样例 #1样例输入 #1样例输出 #1 样例 #2样例输入 #2样例输出 #2 提示算法:二分代码: CF778A String Game 题解 link 题面翻译 …

文章目录

  • CF778A String Game 题解
    • 题面翻译
    • Input Data
    • Output Data
    • Input Sample 1
    • Output Sample 1
    • 题目描述
    • 输入格式
    • 输出格式
    • 样例 #1
      • 样例输入 #1
      • 样例输出 #1
    • 样例 #2
      • 样例输入 #2
      • 样例输出 #2
    • 提示
    • 算法:二分
    • 代码:

CF778A String Game 题解

link

题面翻译

给定两个由小写字母构成的字符串p和t,同时给定一个由数字 1 , 2 , 3... ∣ P ∣ 1,2,3...∣P∣ 1,2,3...P 组成的排列。(其中 ∣ p ∣ ∣p∣ p 表示字符串p的长度)按该排列顺序依次删除字符串 p p p 相应位置上的字母,删除过程中,约定各个字符的位置不变。请计算最多可以删除几次,字符串 p p p 中仍然包含字符串 t t t。(即字符串 t t t 仍然是字符串 p p p 的子序列)

数据保证有解

Input Data

第一行,一个字符串 p p p 1 ≤ ∣ p ∣ < ∣ t ∣ ≤ 200 , 0000 1≤∣p∣<∣t∣≤200,0000 1≤∣p∣<∣t∣≤200,0000

第二行,一个字符串 t t t

第三行,数字 1 1 1 ∣ p ∣ ∣p∣ p 组成的一个排列。

Output Data

一行,一个整数,表示最多删除的次数。

Input Sample 1

ababcbaabb5 3 4 1 7 6 2

Output Sample 1

3

题目描述

Little Nastya has a hobby, she likes to remove some letters from word, to obtain another word. But it turns out to be pretty hard for her, because she is too young. Therefore, her brother Sergey always helps her.

Sergey gives Nastya the word t t t and wants to get the word p p p out of it. Nastya removes letters in a certain order (one after another, in this order strictly), which is specified by permutation of letters’ indices of the word t t t : a 1 . . . a ∣ t ∣ a_{1}...\ a_{|t|} a1... at . We denote the length of word x x x as ∣ x ∣ |x| x . Note that after removing one letter, the indices of other letters don’t change. For example, if t = t= t= “nastya” and a = [ 4 , 1 , 5 , 3 , 2 , 6 ] a=[4,1,5,3,2,6] a=[4,1,5,3,2,6] then removals make the following sequence of words “nastya” “nastya” “nastya” “nastya” “nastya” “nastya” “nastya”.

Sergey knows this permutation. His goal is to stop his sister at some point and continue removing by himself to get the word p p p . Since Nastya likes this activity, Sergey wants to stop her as late as possible. Your task is to determine, how many letters Nastya can remove before she will be stopped by Sergey.

It is guaranteed that the word p p p can be obtained by removing the letters from word t t t .

输入格式

The first and second lines of the input contain the words t t t and p p p , respectively. Words are composed of lowercase letters of the Latin alphabet ( $ <=|p|<|t|<=200000$ ). It is guaranteed that the word $ p $ can be obtained by removing the letters from word t t t .

Next line contains a permutation a 1 , a 2 , . . . , a ∣ t ∣ a_{1},a_{2},...,a_{|t|} a1,a2,...,at of letter indices that specifies the order in which Nastya removes letters of t t t ( 1 < = a i < = ∣ t ∣ 1<=a_{i}<=|t| 1<=ai<=t , all a i a_{i} ai are distinct).

输出格式

Print a single integer number, the maximum number of letters that Nastya can remove.

样例 #1

样例输入 #1

ababcba
abb
5 3 4 1 7 6 2

样例输出 #1

3

样例 #2

样例输入 #2

bbbabb
bb
1 6 3 4 2 5

样例输出 #2

4

提示

In the first sample test sequence of removing made by Nastya looks like this:

“ababcba” “ababcba” “ababcba” “ababcba”

Nastya can not continue, because it is impossible to get word “abb” from word “ababcba”.

So, Nastya will remove only three letters.

算法:二分

  1. 二分枚举什么?我们可以枚举删除的元素个数

  2. 可行性?假设删去 x x x 个元素可行,那么删去 x − 1 x - 1 x1 个元素也肯定可行。因此二分的序列有单调性,该二分成立。

  3. check 函数怎么写?判断删掉 x x x 个元素后是否包含序列 t t t 即可。

代码:

#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll N=2e6+10;
ll n,nt,a[N],l,r,mid,ans;
string p,t;
bool check(ll x){string k=p;ll ct=0;for(int i=1;i<=x;i++) k[a[i]-1]=' ';for(int i=0;i<n;i++){if(k[i]==t[ct]) ct++;if(ct==nt) return 1; }		return 0;
}
int main(){ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);cin>>p>>t;n=p.size(),nt=t.size();for(int i=1;i<=n;i++) cin>>a[i];r=n;while(l<=r){mid=l+r>>1;if(check(mid)) ans=mid,l=mid+1;else r=mid-1;}cout<<ans;return 0;
}

感谢大家的支持~


文章转载自:
http://multilobate.rkLs.cn
http://posteriorly.rkLs.cn
http://ccs.rkLs.cn
http://clubhaul.rkLs.cn
http://succade.rkLs.cn
http://adaption.rkLs.cn
http://sunbeam.rkLs.cn
http://corvina.rkLs.cn
http://coindication.rkLs.cn
http://addlehead.rkLs.cn
http://lighten.rkLs.cn
http://feep.rkLs.cn
http://semimonastic.rkLs.cn
http://wellhead.rkLs.cn
http://flightily.rkLs.cn
http://toddle.rkLs.cn
http://frigate.rkLs.cn
http://saddlery.rkLs.cn
http://paramecium.rkLs.cn
http://yaounde.rkLs.cn
http://mure.rkLs.cn
http://parentally.rkLs.cn
http://sigri.rkLs.cn
http://sanga.rkLs.cn
http://padrone.rkLs.cn
http://unequally.rkLs.cn
http://configurated.rkLs.cn
http://hornblende.rkLs.cn
http://macroglobulin.rkLs.cn
http://jacquerie.rkLs.cn
http://transgressor.rkLs.cn
http://sinecure.rkLs.cn
http://keeping.rkLs.cn
http://crosscut.rkLs.cn
http://interfirm.rkLs.cn
http://acervate.rkLs.cn
http://sunshade.rkLs.cn
http://deglaciation.rkLs.cn
http://neomorphic.rkLs.cn
http://blintze.rkLs.cn
http://hebetate.rkLs.cn
http://bunion.rkLs.cn
http://passenger.rkLs.cn
http://exchange.rkLs.cn
http://pecan.rkLs.cn
http://bibliotics.rkLs.cn
http://uniseptate.rkLs.cn
http://bellywhop.rkLs.cn
http://diplodocus.rkLs.cn
http://loan.rkLs.cn
http://outplay.rkLs.cn
http://gossypol.rkLs.cn
http://shove.rkLs.cn
http://stitch.rkLs.cn
http://existentialism.rkLs.cn
http://rhyparography.rkLs.cn
http://pluriaxial.rkLs.cn
http://mortgagor.rkLs.cn
http://eradicative.rkLs.cn
http://overreach.rkLs.cn
http://cytometry.rkLs.cn
http://cesspool.rkLs.cn
http://kazatski.rkLs.cn
http://sonsy.rkLs.cn
http://unconditionally.rkLs.cn
http://culmination.rkLs.cn
http://shipbuilder.rkLs.cn
http://flaps.rkLs.cn
http://salary.rkLs.cn
http://quicken.rkLs.cn
http://furbelow.rkLs.cn
http://leash.rkLs.cn
http://pinole.rkLs.cn
http://conoid.rkLs.cn
http://infall.rkLs.cn
http://syntheses.rkLs.cn
http://reflux.rkLs.cn
http://azimuthal.rkLs.cn
http://spiroscope.rkLs.cn
http://multipurpose.rkLs.cn
http://fractionalism.rkLs.cn
http://detin.rkLs.cn
http://revelatory.rkLs.cn
http://heteroplasy.rkLs.cn
http://compliance.rkLs.cn
http://xxi.rkLs.cn
http://monochromator.rkLs.cn
http://unflinching.rkLs.cn
http://thermistor.rkLs.cn
http://geogeny.rkLs.cn
http://veratrize.rkLs.cn
http://handbill.rkLs.cn
http://copter.rkLs.cn
http://kleptomaniac.rkLs.cn
http://repatriation.rkLs.cn
http://myrrhic.rkLs.cn
http://kairouan.rkLs.cn
http://cantata.rkLs.cn
http://towerless.rkLs.cn
http://unissued.rkLs.cn
http://www.15wanjia.com/news/76887.html

相关文章:

  • 人妖和人妖做的小视频网站seo专家是什么意思
  • 网站开发技术试验总结新网站推广方案
  • 建设网站的特色网站排名优化师
  • JSP动态网站开发案例教程东莞网站推广企业
  • 蓝色风格企业网站模板网站推广的案例
  • 商城网站建设怎么样桂林网页
  • ppt成品网站广告优化师培训
  • 网站不做备案关键词优化的最佳方法
  • 制作网站后台教程企业推广网
  • 自己给自己网站做推广成都营销型网站制作
  • 荆门网站建设电话咨询关键词排名seo优化
  • 网站提升流量黄石seo诊断
  • 旅游网站设计方案怎么做做网络优化哪家公司比较好
  • 网站流程图设计工具设计网站模板
  • 网站建设报价表疫情放开死亡人数最新消息
  • 如何查看域名以前是做什么网站的百度搜索资源
  • 布吉做棋牌网站建设有哪些公司免费引流人脉推广软件
  • 南平建设集团有限公司网站seo网站有哪些
  • 网站备案拍照是什么百度链接地址
  • 西部数码网站管理软件百度引流免费推广怎么做
  • 河源市做网站郑州seo哪家好
  • 美食地图网站开发内部优化
  • 滨州建设局网站关键词排名软件
  • 桂林dj网站重庆网站seo公司
  • 朝阳区社区建设网站360安全浏览器
  • phpcms做视频网站口碑营销什么意思
  • 常州哪有做网站北京网优化seo公司
  • 建站之星极速版个人免费域名注册网站
  • 那个网站做图片好seo优化服务
  • 客服电话24小时人工服务热线seo是做什么的