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. JavaWeb 02_servlet基础

    1. servlet是什么?作用? 1) Servlet 是Sun公司制定的一套技术标准,包含与Web应用相关的一系列接口,是Web应用实现方式的宏观解决方案I而具体的Servlet容器负责提供标准的 ...

  2. C/C++ 文件读写

    •前言 第一次接触文件读写是在大一的C语言教材中,当时哼哧吧唧的学的贼费劲,虽然最后也学会了,但好像没怎么用过. 在后来,就是在OJ上刷题的时候,编写的代码有时候连样例都不能通过: 这个时候就需要各种 ...

  3. C#拾遗补阙【01】:字符串

    一.string是特殊的引用类型 ​ 众所周知,string是引用类型.为什么string是引用类型,最简单的方法,f12转到string的定义.显而易见,string的本质是类,字符串存储在堆中,而 ...

  4. linux管理用户(组)与相关问题处理

    相关联文件如下: /etc/passwd/etc/shadow/etc/group ================================= [切换当前用户为root]sudo -i [创建 ...

  5. Spring @Configuration继承

    Bean定义继承 Bean定义可以包含许多配置信息,包括构造函数参数,属性值和特定于容器的信息,例如初始化方法,静态工厂方法名称等.子bean定义从父定义继承配置数据.子定义可以覆盖某些值或根据需要添 ...

  6. Spring Cloud 解决了哪些问题?

    在使用 Spring Boot 开发分布式微服务时,我们面临的问题很少由 Spring Cloud解决.与分布式系统相关的复杂性 – 包括网络问题,延迟开销,带宽问题,安 全问题.处理服务发现的能力 ...

  7. 区分 BeanFactory 和 ApplicationContext?

    BeanFactory ApplicationContext 它使用懒加载 它使用即时加载 它使用语法显式提供资源对象 它自己创建和管理资源对象 不支持国际化 支持国际化 不支持基于依赖的注解 支持基 ...

  8. 什么是 Spring 的依赖注入?

    依赖注入,是 IOC 的一个方面,是个通常的概念,它有多种解释.这概念是说你 不用创建对象,而只需要描述它如何被创建.你不在代码里直接组装你的组件和 服务,但是要在配置文件里描述哪些组件需要哪些服务, ...

  9. 分布式存储---FastDFS+GlusterFS

    一. 存储概念 1.块存储的多种实现: 块存储: 就好比硬盘一样, 直接挂在到主机,一般用于主机的直接存储空间和数据库应用的存储 1.磁盘+LVS: 单机硬盘纯存储 2.DAS(DELL MD系列): ...

  10. Markdown入门操作

    Markdown基本操作 一. 字体 1. 标题 (1). 一级标题 "# + 标题名" (2). 其余类推 (最多支持6级标题) 加粗 " ** + 内容 + ** & ...