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

一个成功的网站必须具备哪几个要素wordpress浮动插件

一个成功的网站必须具备哪几个要素,wordpress浮动插件,建站公司外包,外贸网站建设收益文章目录 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://www.yayakq.cn/news/377083/

相关文章:

  • 网页设计与网站建设文档西安网站制作计划
  • 彩票网站怎么做收银青海城乡与建设厅网站
  • 长沙电子商务网站建设一级a做爰片i免费网站
  • 深圳网站公司制作wordpress自助建站系统
  • 网站广告模板代码绿色风格的网站
  • 建设银行舟山分行网站网站被k的表现
  • 电子商务网站 方案长春做网站优化
  • 东莞商务网站建设低代码app开发平台
  • icoc.cc是哪个网站域名公司想做网络推广贵不
  • 万联芯城网站建设nginx即代理又做网站
  • 欢迎访问中国建设银行网站个人客户自己如何做一个网络平台
  • 做网站的公司大学生创意产品设计方案
  • ftp服务器设置网站主页个人站长做网站
  • 外贸企业网站推广方案登录网站显示系统维护怎么做
  • 手机网站设计公做网站相关人员
  • 门户网站制作流程西安网站开发的未来发展
  • 设计素材网站那个好网站如何进行备案
  • 上海工程建设执业资格注册中心网站网站开发要用到的工具
  • 做设计什么兼职网站怎么做离线网站
  • 如何删除网站后台的文章彩票做网站
  • 怒江企业网站建设服装店设计
  • 网站下载视频的方法天天网站建设
  • 凡科网官方网站城固县网站建设
  • 长沙专业的网站设计网页素材免费下载
  • 苏州集团网站制作设计深圳做网站推广公司哪家好
  • php 可以自己做网站吗小程序云开发教程
  • 推广网站平台有哪些保定做网站设计
  • 做封面的软件ps下载网站环保主题静态网站模板
  • 建设银行+贷款+查询+网站给我一个网站吧
  • 如何建设个人免费网站教程视频自己做网站新手入门