2387: Square Pool

Memory Limit:128 MB Time Limit:1.000 S
Creator:
Submit:5 Solved:0

Description

Ron wants to build a square pool in his square N-by-N yard, but his yard contains T trees. Your job is to determine the side length of the largest square pool he can build.
罗恩想在他的 N×N 大小的正方形院子里建一个正方形泳池,但院子里有 T 棵树。 您的任务是确定他能建造的最大正方形泳池的边长。

Input

The first line of input will be an integer N with N ≥ 2. 
The second line will be the positive integer T where T < N2
The remaining input will be T lines, each representing the location of a single tree. The location is given by two positive integers, R and then C, separated by a single space. Each tree is located at row R and column C where rows are numbered from top to bottom from 1 to N and columns are numbered from left to right from 1 to N. No two trees are at the same location. 

输入的第一行将是一个整数 N,其中 N ≥ 2。
第二行将是正整数 T,其中 T < N²。
剩余的输入将是 T 行,每行表示一棵树的位置。位置由两个正整数 R 和 C 给出,中间由一个空格分开。每棵树位于 R 行 C 列,其中行从上到下从 1 到 N 编号,列从左到右从 1 到 N 编号。没有两棵树位于相同的位置。

Output

Output one line containing M which is the largest positive integer such that some M-by-M square contained entirely in Ron’s yard does not contain any of the T trees.
输出一行包含一个正整数 M,这是最大的正整数,使得罗恩院子内的某个 M×M 的正方形区域不包含任何一棵 T 棵树。

Sample Input

15
8
4 7
4 1
14 11
10 6
13 4
4 10
10 3
9 14

Sample Output

7

HINT

A picture of the yard is below. The location of each tree is marked by TREE and one of several 7-by-7 squares that do not contain a tree is highlighted. All larger squares contain a tree.

Source/Category