https://oj.neu.edu.cn/problem/1505

题意:一张由n*n的照片,每行从第ai个像素点到第bi个像素点是非模糊点,要求找出最大的正方形,该正方形中的像素都是非模糊点。

思路:这题有个很巧的地方"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. "

这就否定了以下这种情况,那就可以O(n)暴力移动边界了,枚举第1~n行为上边界,ans从1开始,然后对于第i行判定ans是否可行,若可行则ans++继续该行的判定,否则i++开始下一行的判定。每次判定只需判定上边界和下边界两行即可。

11111

11100

11111

#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e5+10;
int l[maxn],r[maxn];
int n; inline bool check(int up,int d){
if(l[up]+d-1>r[up]) return false;
if(up+d-1>n) return false;
int down = up+d-1;
int left = max(l[up],l[down]);
if(left+d-1<=r[up]&&left+d-1<=r[down]) return true;
return false;
} int main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
while(cin>>n){
for(int i=1;i<=n;i++) cin>>l[i]>>r[i];
int ans = 1;
for(int i=1;i<=n;i++) {
while(check(i,ans+1)) ++ans;
}
cout<<ans<<endl;
}
return 0;
}

neuoj Blurred Pictures(小思维题的更多相关文章

  1. BZOJ4401: 块的计数 思维题

    Description 小Y最近从同学那里听说了一个十分牛B的高级数据结构——块状树.听说这种数据结构能在sqrt(N)的时间内维护树上的各种信息,十分的高效.当然,无聊的小Y对这种事情毫无兴趣,只是 ...

  2. CodeForces - 631C ——(思维题)

    Each month Blake gets the report containing main economic indicators of the company "Blake Tech ...

  3. 计蒜客 28319.Interesting Integers-类似斐波那契数列-递推思维题 (Benelux Algorithm Programming Contest 2014 Final ACM-ICPC Asia Training League 暑假第一阶段第二场 I)

    I. Interesting Integers 传送门 应该是叫思维题吧,反正敲一下脑壳才知道自己哪里写错了.要敢于暴力. 这个题的题意就是给你一个数,让你逆推出递推的最开始的两个数(假设一开始的两个 ...

  4. hdu5325 树的思维题

    pid=5325">http://acm.hdu.edu.cn/showproblem.php? pid=5325 Problem Description Bobo has a tre ...

  5. [CF1244C] The Football Season【数学,思维题,枚举】

    Online Judge:Luogu,Codeforces Round #592 (Div. 2) C Label:数学,思维题, 枚举 题目描述 某球队一共打了\(n\)场比赛,总得分为\(p\), ...

  6. [Hdu-5155] Harry And Magic Box[思维题+容斥,计数Dp]

    Online Judge:Hdu5155 Label:思维题+容斥,计数Dp 题面: 题目描述 给定一个大小为\(N*M\)的神奇盒子,里面每行每列都至少有一个钻石,问可行的排列方案数.由于答案较大, ...

  7. [SHOI2007] 书柜的尺寸 思维题+Dp+空间优化

    Online Judge:Luogu-P2160 Label:思维题,Dp,空间优化 题面: 题目描述 给\(N\)本书,每本书有高度\(Hi\),厚度\(Ti\).要摆在一个三层的书架上. 书架的宽 ...

  8. 7月15日考试 题解(链表+状压DP+思维题)

    前言:蒟蒻太弱了,全打的暴力QAQ. --------------------- T1 小Z的求和 题目大意:求$\sum\limits_{i=1}^n \sum\limits_{j=i}^n kth ...

  9. Xor 思维题

    Xor 思维题 题目描述 小\(Q\)与小\(T\)正在玩一棵树.这棵树有\(n\)个节点,编号为 \(1\),\(2\) \(3...n\),由\(n-1\)条边连接,每个节点有一个权值\(w_i\ ...

随机推荐

  1. [POJ1772] Substract

    问题描述 We are given a sequence of N positive integers a = [a1, a2, ..., aN] on which we can perform co ...

  2. Python3解leetcode Kth Largest Element in a Stream

    问题描述: Design a class to find the kth largest element in a stream. Note that it is the kth largest el ...

  3. 笨办法学Python(learn python the hard way)--练习程序31-35

    下面是练习31-练习35,基于python3 #ex31.py 1 print("You enter a dark room witn two doors. Do you go throug ...

  4. /usr/bin/ld: cannot find -lgcc_s 问题解决小记

    /usr/bin/ld: cannot find -lgcc_s 问题解决小记 博客分类: Linux/Ubuntu 由于之前用wubi装的ubuntu并且只给了它10G的硬盘空间,随着学习的深入这种 ...

  5. 术语-PM:PM/项目管理 百科

    ylbtech-术语-PM:PM/项目管理 百科 PM项目管理(Project Management),是以项目为对象的系统管理方法,通过一个临时性的.专门的柔性组织,对项目进行高效率的计划.组织.指 ...

  6. 穿戴-智能穿戴-ProjectGlass:谷歌眼镜(Google Project Glass)

    ylbtech-穿戴-智能穿戴-ProjectGlass:谷歌眼镜(Google Project Glass) 谷歌眼镜(Google Project Glass)是由谷歌公司于2012年4月发布的一 ...

  7. 132、TensorFlow加载模型

    # The tf.train.Saver对象不仅保存变量到checkpoint文件 # 它也恢复变量,当你恢复变量的时候,你就不必须要提前初始化他们 # 列如如下的代码片段解释了如何去调用tf.tra ...

  8. JDK 5.0 新增解决线程安全 Callable接口和线程池

    在jdk5.0后又新增了两种解决线程安全的问题 一: 实现Callable接口, 实现接口步骤: 1: 创建一个实现Callable接口的实现类 2: 实现Callable接口中的call()方法, ...

  9. This service allows sftp connections only

    这是因为该用用户只开通了sftp,ssh被禁了 可以通过别的主机ssh登陆这台机器 app@home:/software>ssh mysftp@192.168.0.1 Authorized on ...

  10. Jenkins+GitLab持续集成

    向GitLab提交代码之后自动触发Jenkins构建 https://baijiahao.baidu.com/s?id=1630678692475452408&wfr=spider&f ...