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

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还是要多学习的更多相关文章
- 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 ...
- Codeforces Round #704 (Div. 2)
A. Three swimmers 题意:第一个人跳水是每隔a分钟去一次,第二个人跳水是每隔b分钟,第三个人跳水是每隔c分钟,一个人准备在p分钟的 时候去跳水,问需要最少等待多长时间才能轮到前三个人 ...
- 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 ...
- 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 ...
- 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 ...
- Codeforces Round #753 (Div. 3), problem: (D) Blue-Red Permutation
还是看大佬的题解吧 CFRound#753(Div.3)A-E(后面的今天明天之内补) - 知乎 (zhihu.com) 传送门 Problem - D - Codeforces 题意 n个数字,n ...
- Codeforces Round #243 (Div. 2) Problem B - Sereja and Mirroring 解读
http://codeforces.com/contest/426/problem/B 对称标题的意思大概是.应当指出的,当线数为奇数时,答案是线路本身的数 #include<iostream& ...
- 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 ...
- 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 ...
随机推荐
- Nacos+OpenFegin正确调用服务的姿势!
Nacos 支持两种 HTTP 服务请求,一个是 REST Template,另一个是 Feign Client.之前的文章咱们介绍过 Rest Template 的调用方式,主要是通过 Ribbon ...
- kubernetes允许master调度
1,让 Master 也当作 Node 使用 (1)如果想让 Pod 也能调度到在 Master(本样例即 localhost.localdomain)上,可以执行如下命令使其作为一个工作节点: 注意 ...
- zabbix图形中文乱码
别的贴子都是说到修改/usr/share/zabbix/include/defines.inc.php中的 define('ZBX_FONT_NAME', 'msyh'); define('ZBX_G ...
- ansible 二主机和组
主机清单的管理 Ansible安装好之后的主机清单配置文件有如下两种: 1.yum安装,配置文件默认路径为: /etc/ansible/hosts 2.源码包安装,主机清单配置文件路径需要从软件包里面 ...
- java中对集合操作的易错点01
今天用for循环遍历集合,对集合中满足条件的元素进行remove操作报错:ConcurrentModificationException 所以,在遍历集合进行增.删操作时,要使用迭代器的方式 publ ...
- phpmyadmin 4.8.1 文件包含漏
一. 启动环境 1.双击运行桌面phpstudy.exe软件 2.点击启动按钮,启动服务器环境 二.代码审计 1.双击启动桌面Seay源代码审计系统软件 3.点击新建项目按钮,弹出对画框中选择(C:\ ...
- 老徐和阿珍的故事:CAP是什么?超级爱放P吗?
人物背景: 老徐,男,本名徐福贵,从事Java相关研发工作多年,职场老油条,摸鱼小能手,虽然岁数不大但长的比较着急,人称老徐.据说之前炒某币败光了所有家产,甚至现在还有欠债. 阿珍,女,本名陈家珍,刚 ...
- 用Markdown写Html和.md也就图一乐,真骚操作还得用来做PPT
前言 和这篇文章一样,我就是用Markdown写的.相信各位平时也就用Markdown写写文档,做做笔记,转成XHtml.Html等,今天教大伙一招骚操作:用Markdown写PPT. 绝大多数朋友做 ...
- github新手使用指南
常用命令: Git 速查表(摘自 AI有道) 一.常见命令 git init : 初始化 git 仓库,即将一个文件夹初始化为一个 git 仓库.具体的操作是创建一个 .git 隐藏文件夹 git ...
- Oracle入门基础(十)一一数据库其他对象-视图/序列/索引/同义词
SQL> --视图 SQL> create view empinfoview as select e.empno,e.ename,e.sal,e.sal*12 annsal,d.dname ...