codeforces contest 779 D题

开源光标主题实战:从Moshi Monsters到自定义指针的完整指南 光标主题是操作系统个性化的重要组成部分,它通过替换系统默认指针图标来改变视觉交互体验。其原理在于操作系统允许用户自定义指针资源文件,这些文件定义了不同状态下的光标图像。从技术价值看,一套设计良好的光标主题不仅能提升桌面美观度,还能增强用户的情感连接和操作愉悦感,是低成本高回报的数字幸福感提升方案。在应用场景上,无论是开发者、设计师还是普通用户,都可以通过更换光标主题来个性化工作环境。本文以热门的Moshi Monsters开源光标项目为例,深入解析了光标主题的设计逻辑、系统适配方案以及二次创作方法,涵盖了W 阅读详情

D. String Game
time limit per test2 seconds
memory limit per test512 megabytes
inputstandard input
outputstandard output
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 and wants to get the word 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: a1… a|t|. We denote the length of word x as |x|. Note that after removing one letter, the indices of other letters don’t change. For example, if t = “nastya” and 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. 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 can be obtained by removing the letters from word t.

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

Next line contains a permutation a1, a2, …, a|t| of letter indices that specifies the order in which Nastya removes letters of t (1 ≤ ai ≤ |t|, all ai are distinct).

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

Examples
input
ababcba
abb
5 3 4 1 7 6 2
output
3
input
bbbabb
bb
1 6 3 4 2 5
output
4
Note
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.

题意:给你两个字符串,p和t,然后给你一个长度为|p|的整数数组,按照这个数组的第一个元素到最后一个元素,每次删除在p中对应位置为a[i]的字符,问你,最多能删除多少个,能使剩下的字符任然能组成t字符串。

解题思路:二分答案就行。

#include<bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
int a[maxn];
char p[maxn];
char t[maxn];
bool visit[maxn];
char term[maxn];
int len1;
int len2;
bool ok(int x)
{
    memset(visit,false,sizeof(visit));
    for(int i = x + 1; i < len1; i++)
    {
       visit[a[i]] = true;
    }
    int cnt = 0;
    for(int i = 0; i < len1; i++)
    {
        if(visit[i]) term[cnt++] = p[i];
    }
    if(cnt < len2) return false;
    int loc = 0;
    for(int i = 0; i < cnt; i++)
    {
        if(term[i] == t[loc])
        {
            loc++;
            if(loc == len2) break;
        }
    }
    if(loc == len2) return true;
    else return false;
}
int main()
{
    scanf("%s",p);
    scanf("%s",t);
    len1 = strlen(p);
    len2 = strlen(t);
    for(int i = 0; i < len1; i++)
    {
        scanf("%d",&a[i]);
        a[i]--;
    }
    int l = 0;
    int r = len1 - 1;
    int result = -1;
    while(l <= r)
    {
        int mid = (l + r)>>1;
        if(ok(mid))
        {
            result = mid;
            l = mid + 1;
        }
        else r = mid - 1;
    }
    printf("%d\n",result + 1);
}

【学习系列】SAP RAP 17:RAP应用部署集成至Fiori Launchpad 【S4HC Public Edition】 本文详细介绍了在SAP S/4HANA Cloud环境中部署RAP应用集成到Fiori Launchpad的两种方法:使用BAS(SAP Business Application Studio)和VSCode。主要步骤包括:1)在BTP中配置Destination连接ES环境;2)设置信任关系;3)创建BAS开发空间;4)通过Fiori应用生成器部署RAP应用;5)创建IAM App、Business Catalog和Business Role;6)配置Launchpad Space和Pages。文章还提供 阅读详情

相关推荐

Hi3559AV100制作ext4文件系统和烧录emmc

1、首先生成所需文件系统,见本博客&lt;Hi3559AV100文件系统制作cramfs&gt;。 2、使用工具生成EXT4文件系统 ./make_ext4fs -s -l 96M rootfs_hi3559av100.ext4 ./rootfs 3、烧录文件系统 mw.b 0x82000000 ff 0x12C00000;tftp 0x82000000 STM_...

阿Sir问道 7034

CF778A String Game 题解

相应位置上的字母,删除过程中,约定各个字符的位置不变。请计算最多可以删除几次,字符串。给定两个由小写字母构成的字符串p和t,同时给定一个由数字。因此二分的序列有单调性,该二分成立。表示字符串p的长度)按该排列顺序依次删除字符串。一行,一个整数,表示最多删除的次数。个元素后是否包含序列。个元素可行,那么删去。

见合8的博客 1283

网络安全面试题

在当今社会网络安全行业越来越发达,也有越来越多的人去学习,为了更好地进行工作,除了学好知识外还要应对企业的面试。 所以在这里我归总了一些网络安全方面的常见面试题,希望对大家有所帮助。 windows常见 1:描述tcp/udp的区别及优劣,及其发展前景 TCP—传输控制协议,提供的是面向连接、可靠的字节流服务。当客户和服务器彼此交换数据前,必须先在双方之间建立一个TCP连接,之后才能...

fzx_hsaj的博客 6万+

第二次训练赛总结(二分)

第一题: 第二题: 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 Se...

beautfullboy的博客 427

后仿真中的关于延时问题(物理特性角度)

大家都知道,后仿真讲究仿真时序。那么,在网表阶段,接触到后仿延时问题。今天总结一下。

那么菜的博客 1772

相似贴子推荐:基于 LangChain4j + Milvus 的混合检索实战

本文提出了一种基于LangChain4j和Milvus的混合检索方案,用于解决论坛社区中的相似帖子推荐问题。该方案结合稠密向量语义检索和BM25关键词检索的优势,通过RRF算法实现结果融合。系统采用bge-small-zh模型生成语义向量,利用Milvus 2.5+原生支持的BM25功能和混合搜索API,在百万级数据规模下实现50ms内的检索延迟,召回率和精确率分别提升15%和22%。文章详细介绍了从数据预处理、向量化到混合检索的完整实现流程,并探讨了进阶优化方向,为推荐系统和RAG应用提供了高效解决方案。

分享AI、区块链技术及应用,未来已来 88

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

D. String GameLittle 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 b...

baan7498的博客 273

SmartFusion从FPGA到ARM(九)——串口命令解析器的实现

系列教程:SmartFusion从FPGA到ARM系列教程 前面两节介绍了MSS_UART和CoreUARTapb的使用: MSS_UART的使用 CoreUARTapb的使用 MSS_UART和CoreUARTapb都支持中断和轮询方式获取串口接收的数据,对于串口中断服务函数,有时我们需要通过不同的串口指令去执行不同的动作,下面以CoreUARTapb为例,来实现一个简单的串口命令解析器。固定串口数据帧格式,帧长度不定。 串口数据帧格式:* + 数据 + #,对于数据中为参数的,可以自定义处理函数。例

whik1194的博客 1535

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 input output standard output Little Nastya has a hobby, she likes to remo

spark__s的博客 363

反应堆设计:基于MATLAB的反应堆仿真和分析,包括反应堆稳态分析、反应堆动态分析和反应堆安全分析 介绍

反应堆设计是利用计算机技术对核反应堆进行设计和模拟,以获得安全、高效、经济的核能发电系统。它是核能领域的重要组成部分,在电力生产、核医学、科学研究等领域有着广泛的应用。

走向CTO的路上... 1112

VSCode 配置 Claude Code 插件的 4 步安装法与 3 类常见报错解决方案

介绍 VSCode 中 Claude Code 插件的 4 步可靠安装流程与 3 类高频报错(上下文丢失、认证失败、加载卡死)的根因分析和精准修复方案,聚焦文件上下文捕获机制、请求头注入要求及缓存失效逻辑,提供可验证的命令行操作与日志定位方法。

weixin_28728443的博客 496

Transformer时间序列预测-多变量输入-单变量输出+多变量输出,完整代码数据,可直接运行

Transformer时间序列预测-多变量输入-单变量输出+多变量输出,完整代码数据,可直接运行

9794

codeforces 779d

D. String Game time limit per test 2 seconds memory limit per test 512 megabytes input standard input output standard output Little Nastya has a hobby, she likes to remove some letters from w

Hi_jiaxinwei的博客 777

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

Statistics and Machine Learning Toolbox

Statistics and Machine Learning Toolbox(带书签),MATLAB统计学习工具

codeforces 2017 JUST Programming Contest B Array Reconstructing

B 题意: 准确的意思就是给的一串数,不清楚的为-1,清楚的那个数,每前面一个是这个数减一,后一个是加一。且是按照0到m-1的一次次循环 (PS: 开头的数不一定确定,也可能是-1 (我一开始一直做不出来就是因为那个 1<i <=n,以为第一个数一定有赋值,却忽视了,要i不大于一,怎么i-1!!!) 思路: 其实方法挺多的吧。 1.根据数遍历,找到第一个被赋值的数,然后再这个数前面减一,到0以后回复m-1,后面的数加一%m 2. 也是找到第一个被赋值的数,然后推出第一个数是多少,然后按位

SRT_HD的博客 319

STM32F407中文手册

STM32f407中文手册 本参考手册面向应用开发人员,提供有关使用 STM32F405xx/07xx、STM32F415xx/17xx、 STM32F42xxx 和 STM32F43xxx 微控制器存储器与外设的完整信息。STM32F405xx/07xx、STM32F415xx/17xx、STM32F42xxx 和 STM32F43xxx 构成一个微 控制器系列,各产品具有不同的存储器大小、封装和外设。有关订购信息以及器件的机械与电气特性,请参见数据手册。有关 ARM Cortex™-M4F 内核的信息,请参见《Cortex™-M4F 技术参考手册》。

ACM刷题之Codeforces ————String Game

String Game time limit per test 2 seconds memory limit per test 512 megabytes input standard input output standard output Little Nastya has a hobby, she likes to remove

小时的枫的博客 1028

RU DOS版、EFI版32bit/64bit BIOS常用工具

DOS版、EFI版的RU工具,可用来查看IO、MEM、PCI、SMBIOS等资源。亲测在EFI SHELL下可用。

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

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

chutzpah 427

Codeforces 778A-String Game

String Game time limit per test 2 seconds memory limit per test 512 megabytes input standard input output standard output Little Nastya has a hobby, she likes to remove

wang_128的博客 978

Codeforces 778A(二分答案)

Codeforces 778A String Game题目: String Game time limit per test2 seconds memory limit per test512 megabytes inputstandard input outputstandard output Little Nastya has a hobby, she likes to remov

Static_Ricardo的博客 1071

Codeforces Round #402 (Div2)D题

D. String Game time limit per test 2 seconds memory limit per test 512 megabytes input standard input output standard outputLittle Nastya has a hobby, she likes to remove some letters from word

zt_1995的专栏 462

CodeForces 779D String Game【二分答案】

题目链接:http://codeforces.com/contest/779/problem/D 题意:给你两个字符串s1,s2,再给你一个序列,按序列顺序删除s1中的元素,删除必须保证包含s2这个子串,问你最多能删除多少个字符 解析:因为给出了删除顺序,所以可以直接扫一遍一个一个删除来判断,但是判断的时间复杂度太高,降不下来,所以采用二分答案的方法来解决这道题#include <cstdio>

22h's Blog 599

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 input output standard output Little Nastya has a hobby, she likes to remove some le

mengxiang000000 1476

【Codeforces Round #402 (Div. 1)】Codeforces 778A String Game

二分答案+贪心

YHaX的博客 445

D. String Game----二分答案

D. String Game time limit per test 2 seconds memory limit per test 512 megabytes input standard input output standard output Little Nastya has a hobby, she likes to remo

bless295的博客 454

String Game

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 alway...

qq_42865713的博客 601

【ZCMU1893】String Game(博弈)

题目链接题目大意: 给你两个串a,b,a的长度不小于b 现在有两个人A,B,每次可以选择在a的头或尾删除一个字符,由B先。 直到a的长度等于b,如果此时a与b相等则A赢可以分为三种情况讨论。 1.如果a的长度等于b 就直接看a是否和b相等。 2.如果a的长度减去b的长度是奇数 说明B的操作次数比A多一次。假设A的操作次数是ope 假设b在a的内部 如果B要赢,

No Program No Life 456
上一篇: codeforces contest 779 C题
下一篇: 二进制加构造思维
creatorx
博客等级 码龄10年 127粉丝 145原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值