Problem - C - Codeforces

看清题目要求, 最重要部分在第二段. 大佬最后给出的代码果然简单, 思路简单化, 未必非要把答案在一个大括号里全部完成, 两个指针同时跑,中间加了一堆判断处理, 反而不如返璞归真, 简单清晰为后面改代码也省了很多力气

AC代码

#include <iostream>
#include <algorithm> using namespace std; typedef long long LL;
const int N = 2e5+10;
int q[N], h[N]; int main(){ int n, m;
string s1, s2;
cin >> n >> m >> s1 >> s2;
int res = 0; for(int i = 0, j = 0; i < n; i ++)
if(s1[i] == s2[j]) q[j ++] = i; for(int i = n-1, j = m-1; i >= 0; i --)
if(s1[i] == s2[j]) h[j --] = i; for(int i = 0; i < m; i ++) res = max(res, h[i+1]-q[i]);
cout <<res <<endl;
return 0;
}

Codeforces Round #704 (Div. 2), problem: (C) Maximum width还是要多学习的更多相关文章

  1. Codeforces Round #716 (Div. 2), problem: (B) AND 0, Sum Big位运算思维

    & -- 位运算之一,有0则0 原题链接 Problem - 1514B - Codeforces 题目 Example input 2 2 2 100000 20 output 4 2267 ...

  2. Codeforces Round #704 (Div. 2)

    A. Three swimmers 题意:第一个人跳水是每隔a分钟去一次,第二个人跳水是每隔b分钟,第三个人跳水是每隔c分钟,一个人准备在p分钟的 时候去跳水,问需要最少等待多长时间才能轮到前三个人 ...

  3. Codeforces Round #427 (Div. 2) Problem C Star sky (Codeforces 835C) - 前缀和

    The Cartesian coordinate system is set in the sky. There you can see n stars, the i-th has coordinat ...

  4. Codeforces Round #425 (Div. 2) Problem D Misha, Grisha and Underground (Codeforces 832D) - 树链剖分 - 树状数组

    Misha and Grisha are funny boys, so they like to use new underground. The underground has n stations ...

  5. Codeforces Round #425 (Div. 2) Problem C Strange Radiation (Codeforces 832C) - 二分答案 - 数论

    n people are standing on a coordinate axis in points with positive integer coordinates strictly less ...

  6. Codeforces Round #753 (Div. 3), problem: (D) Blue-Red Permutation

    还是看大佬的题解吧 CFRound#753(Div.3)A-E(后面的今天明天之内补) - 知乎 (zhihu.com) 传送门  Problem - D - Codeforces 题意 n个数字,n ...

  7. Codeforces Round #243 (Div. 2) Problem B - Sereja and Mirroring 解读

    http://codeforces.com/contest/426/problem/B 对称标题的意思大概是.应当指出的,当线数为奇数时,答案是线路本身的数 #include<iostream& ...

  8. Codeforces Round #439 (Div. 2) Problem E (Codeforces 869E) - 暴力 - 随机化 - 二维树状数组 - 差分

    Adieu l'ami. Koyomi is helping Oshino, an acquaintance of his, to take care of an open space around ...

  9. Codeforces Round #439 (Div. 2) Problem C (Codeforces 869C) - 组合数学

    — This is not playing but duty as allies of justice, Nii-chan! — Not allies but justice itself, Onii ...

随机推荐

  1. 5分钟了解Redis的内部实现跳跃表(skiplist)

    跳跃表简介 跳跃表(skiplist)是一个有序的数据结构,它通过在每个节点维护不同层次指向后续节点的指针,以达到快速访问指定节点的目的.跳跃表在查找指定节点时,平均时间复杂度为,最坏时间复杂度为O( ...

  2. 为什么要从Web form过渡到MVC中

    可以说,在未来几年中,Web form的使用会逐渐减少,而取而代之的就是MVC.可能你不会同意我的观点,那么我就试着阐述一下我的观点,如果你还是不能接受,那么请你反驳我. 学习一个新语言或者是新架构是 ...

  3. Active MQ 整合SpringBoot

    配置文件 POM <?xml version="1.0" encoding="UTF-8"?> <project xmlns="ht ...

  4. Flink不止于计算,存算一体才是未来

    ​ "伴随着实时化浪潮的发展和深化,Flink 已逐步演进为实时流处理的领军技术和事实标准.Flink 一方面持续优化其流计算核心能力,不断提高整个行业的流计算处理标准,另一方面沿着流批一体 ...

  5. IDEA 常用快捷键操作

    自定义设置及查询: 操作路径:file-setting-Keymap-Editor actions 右击需要修改的action操作,或者右击Editor actions,选择添加Add Keyboar ...

  6. ApplicationContext通常的实现是什么?

    FileSystemXmlApplicationContext :此容器从一个XML文件中加载beans的定义,XML Bean 配置文件的全路径名必须提供给它的构造函数. ClassPathXmlA ...

  7. Django用mongoengine操作mongodb

    最近在写Django项目,使用的是mongodb,虽然Django不支持NoSQL,但是mongoengine可以帮助我们像ORM一样在Django项目中去操作mongodb 推荐一个可视化工具  R ...

  8. js Object扩展自定义方法,jQuery抛出 Uncaught TypeError: matchExpr[type].exec is not a function

    使用Jquery的时候,想在Object原型上添加自己扩展的方法的时候,启动项目之后,打开网页就会报如上错误信息,经过测试,可以在Object下的具体类型上进行扩展自定义方法,如String,Arra ...

  9. 学习k8s(二)

    kubernetes-国内拉取gcr.io\quay.io镜像方法 方法1: https://hub.docker.com/r/ibmcom/ 例如: gcr.io/google_containers ...

  10. springboot项目如何添加热部署

    环境jdk1.8.maven3.6.使用工具为idea 1.在pom.xml文件中添加依赖 <dependency> <groupId>org.springframework. ...