HNU2019 Summer Training 3 E. Blurred Pictures
2 seconds
256 megabytes
standard input
standard output
Damon loves to take photos of the places he visits during his travels, to put them into frames. All of his photos are in a square format of N×N pixels. He brought back beautiful pictures of the many monuments in Paris, such as the Eiffel Tower or the Louvre, but unfortunately, when he got back home, he realized that all his pictures were blurred on the edges. Looking closely, Damon realizes that he can easily distinguish the blurred pixels from the "good" (i.e., non-blurred) ones and that, luckily, all the non-blurred pixels are connected in such a way that any horizontal or vertical line drawn between two non-blurred pixels goes only through non-blurred pixels. In order to get the best from his failed pictures, he decides to cut out the biggest possible picture without any blurred pixel from each of his photos. And since his frames are all squares, for aesthetic reasons, the cut-out pictures have to be squares too. Damon does not want his pictures to be tilted so he wants the sides of the cut-outs to be parallel to the sides of the original picture.
The input comprises several lines, each consisting of integers separated with single spaces:
- The first line contains the length N, in pixels, of the input photo;
- Each of the next N lines contains two integers ai and bi , the indices of the first (ai)and the last (bi) non-blurred pixel on the i-th line.
- 0<N≤100000,
- 0≤ai≤bi<N.
The output should consist of a single line, whose content is an integer, the length of the largest square composed of non-blurred pixels inside the picture.
3
1 1
0 2
1 1
1
8
2 4
2 4
1 4
0 7
0 3
1 2
1 2
1 1
3
- In the input picture, each row and each column has at least one non-blurred pixel.
- In any two consecutive lines, there are at least two non-blurred pixels in the same column.
代码实现:
#include<iostream>
#include<algorithm>
using namespace std;
#define int long long
const int N=2e5+5;
int l[N],r[N];
signed main(){
int n;
cin>>n;
//题目保证最小为1
int res=1;
//输入每行的左端点和右端点
for(int i=1;i<=n;i++)cin>>l[i]>>r[i];
for(int i=1;i<=n;i++){
while(1){
//如果当前行的长度都小于res,直接换下一行
if(r[i]-l[i]<res)break;
//如果当前行向下越界了,直接返回
if(res+i>n)break;
//记录最终行
int ed=res+i;
//判断第一行和最后一行起始点哪个靠后
int bg=max(l[i],l[ed]);
//如果bg加res小于等第一行右端点且bg加res小于等于最终行右端点,则表示当前行可取,res++,继续往下判断
if(bg+res<=r[i]&&bg+res<=r[ed])res++;
//否则表示当前行已经无法继续向下判断了
else break;
}
}
cout<<res<<endl;
return 0;
}
HNU2019 Summer Training 3 E. Blurred Pictures的更多相关文章
- [Artoolkit] Marker Training
Link: Documentation About the Traditional Template Square Marker Limitations (重要) Traditional Templa ...
- hdu 4946 2014 Multi-University Training Contest 8
Area of Mushroom Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) ...
- 2016 Multi-University Training Contests
2016 Multi-University Training Contest 1 2016 Multi-University Training Contest 2 2016 Multi-Univers ...
- 2016 Multi-University Training Contest 2 D. Differencia
Differencia Time Limit: 10000/10000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Tot ...
- 2016 Multi-University Training Contest 1 G. Rigid Frameworks
Rigid Frameworks Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) ...
- ACM: Gym 101047K Training with Phuket's larvae - 思维题
Gym 101047K Training with Phuket's larvae Time Limit:2000MS Memory Limit:65536KB 64bit IO F ...
- The Solution of UESTC 2016 Summer Training #1 Div.2 Problem C
Link http://acm.hust.edu.cn/vjudge/contest/121539#problem/C Description standard input/output After ...
- 2012 Multi-University Training Contest 9 / hdu4389
2012 Multi-University Training Contest 9 / hdu4389 打巨表,实为数位dp 还不太懂 先这样放着.. 对于打表,当然我们不能直接打,这里有技巧.我们可以 ...
- 2014 Multi-University Training Contest 9#11
2014 Multi-University Training Contest 9#11 Killing MonstersTime Limit: 2000/1000 MS (Java/Others) ...
- 2014 Multi-University Training Contest 9#6
2014 Multi-University Training Contest 9#6 Fast Matrix CalculationTime Limit: 2000/1000 MS (Java/Oth ...
随机推荐
- CAS 6.x + Delegated Authentication SAML2.0 配置记录
最近领导派了一个活儿, 需要把我们CAS系统的身份识别交给甲方的系统, 甲方的系统是SAML2.0的协议. 由于之前对SAML2.0协议了解不多,折腾了不少时间,在这里记录一下.以后忘掉还可以看看. ...
- Cannot read properties of undefined (reading 'toUpperCase')
无法读取 JS 中未定义的属性"toUpperCase"|鲍比哈兹 (bobbyhadz.com) 根据其中的内容找到了答案:使用了未定义的属性去使用toUpperCase()函数 ...
- 循序渐进讲解负载均衡vivoGateway(VGW)
作者:vivo 互联网运维团队- Duan Chengping 在大规模业务场景中,已经不可能通过单机提供业务,这就衍生出了负载均衡的需求.为了满足合适可靠的负载,本文将从简单的基础需求出发,一步步推 ...
- void关键字
在C++中,void表示为无类型,主要有三个用途: (1)函数的 返回值用void,表示函数没有返回值. void func(int a, int b) { //函数体代码 return; } (2) ...
- 这可能是最全面的Spring面试题总结了
Spring是什么? Spring是一个轻量级的控制反转(IoC)和面向切面(AOP)的容器框架. Spring的优点 通过控制反转和依赖注入实现松耦合. 支持面向切面的编程,并且把应用业务逻辑和系统 ...
- pandas之面属行统计
描述统计学(descriptive statistics)是一门统计学领域的学科,主要研究如何取得反映客观现象的数据,并以图表形式对所搜集的数据进行处理和显示,最终对数据的规律.特征做出综合性的描述分 ...
- w10通过修改注册表实现禁止更新系统
对于Windows系统更新或驱动更新,并不是越新越好,当然新版本的系统可能带来了许多新的功能.漏洞修补.漂亮的用户界面和流畅的系统优化等,但是新版本的系统和驱动更新有可能会造成CPU占用居高不下,文件 ...
- python程序,实现以管理员方式运行程序,也就是提升程序权限
quest UAC elevation from within a Python script? 我希望我的Python脚本能够在Vista上复制文件. 当我从普通的cmd.exe窗口运行它时,不会生 ...
- 开心档之MySQL 复制表
MySQL 复制表 如果我们需要完全的复制MySQL的数据表,包括表的结构,索引,默认值等. 如果仅仅使用CREATE TABLE ... SELECT命令,是无法实现的. 本章节将为大家介绍如何完整 ...
- node安装node-sass
安装node-sass使用node版本不能太高,否则会报错 checking for Python executable "C:\Program Files\python" in ...