10204_BigBarn

2022-5-16 18:16| 发布者: Hocassian| 查看: 77| 评论: 0|原作者: 肇庆学院ACM合集

摘要:
C:\Users\Administrator\Downloads\2019-10-12-10-14-3-89504658841800-Problem List-采集的数据-后羿采集器.html

Pro.ID

10204

Title

Big Barn

Title链接

http://10.20.2.8/oj/exercise/problem?problem_id=10204

AC

5

Submit

21

Ratio

23.81%

时间&空间限制

  • Time Limit: 30000/5000 MS (Java/Others)     Memory Limit: 65536/65536 K (Java/Others)
  • 描述

    Farmer John wants to place a big square barn on his square farm. He hates to cut down trees on his farm and wants to find a location for his barn that enables him to build it only on land that is already clear of trees. For our purposes, his land is divided into N × N parcels. The input contains a list of parcels that contain trees. Your job is to determine and report the largest possible square barn that can be placed on his land without having to clear away trees. The barn sides must be parallel to the horizontal or vertical axis.

    EXAMPLE

    Consider the following grid of Farmer John's land where '.' represents a parcel with no trees and '#' represents a parcel with trees:

      1 2 3 4 5 6 7 8
    1 . . . . . . . .
    2 . # . . . # . .
    3 . . . . . . . .
    4 . . . . . . . .
    5 . . . . . . . .
    6 . . # . . . . .
    7 . . . . . . . .
    8 . . . . . . . .

    The largest barn is 5 × 5 and can be placed in either of two locations in the lower right part of the grid.

    输入

    Line 1:   Two integers: N (1 ≤ N ≤ 1000), the number of parcels on a side, and T (1 ≤ T ≤ 10,000) the number of parcels with trees

    Lines 2..T+1:   Two integers (1 ≤ each integer ≤ N), the row and column of a tree parcel

    输出

    Description

    Farmer John wants to place a big square barn on his square farm. He hates to cut down trees on his farm and wants to find a location for his barn that enables him to build it only on land that is already clear of trees. For our purposes, his land is divided into N × N parcels. The input contains a list of parcels that contain trees. Your job is to determine and report the largest possible square barn that can be placed on his land without having to clear away trees. The barn sides must be parallel to the horizontal or vertical axis.

    EXAMPLE

    Consider the following grid of Farmer John's land where '.' represents a parcel with no trees and '#' represents a parcel with trees:

      1 2 3 4 5 6 7 8
    1 . . . . . . . .
    2 . # . . . # . .
    3 . . . . . . . .
    4 . . . . . . . .
    5 . . . . . . . .
    6 . . # . . . . .
    7 . . . . . . . .
    8 . . . . . . . .

    The largest barn is 5 × 5 and can be placed in either of two locations in the lower right part of the grid.

    Input

    Line 1:   Two integers: N (1 ≤ N ≤ 1000), the number of parcels on a side, and T (1 ≤ T ≤ 10,000) the number of parcels with trees

    Lines 2..T+1:   Two integers (1 ≤ each integer ≤ N), the row and column of a tree parcel

    Output

    The output file should consist of exactly one line, the maximum side length of John's barn.

    Sample Input

    8 3
    2 2
    2 6
    6 3

    Sample Output

    5

    Source

    样例输入

    8 3
    2 2
    2 6
    6 3

    样例输出

    5

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部