#P9921. [POI 2023/2024 R1] Budowa lotniska

    ID: 11180 远端评测题 500ms 128MiB 尝试: 0 已通过: 0 显示难度提高 上传者: 标签>POI(波兰)2023前缀和分类讨论

[POI 2023/2024 R1] Budowa lotniska

Background

Translated from XXXI Olimpiada Informatyczna - Stage I Budowa lotniska。

Problem Description

You are given an n×nn \times n map. The map contains . and X.

Find the maximum kk such that:

You can find mm (m≤2)(m \leq 2) strips of size 1×k1 \times k or k×1k \times 1 on the map, such that the strips do not intersect, and every cell inside each strip is .。

Input Format

The first line contains two positive integers n,mn, m。

The next nn lines describe the map。

Output Format

Output one non-negative integer in a single line: the maximum kk。

5 2
.X...
.XXXX
XX...
.....
.X.X.

3

2 1
..
..

2

2 2
X.
..

1

10 2
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
..........
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX

5

10 2
XX.XXXXX.X
XX.XXXXX.X
XX.XXXXX.X
XX.XXXXX.X
XX.XXXXX.X
XX.XXXXX.X
XX.XXXXX.X
XX.XXXXX.X
XX.XXXXX.X
XX.XXXXX.X

10

见附件
531

Hint

Explanation of the sample:

.X...
.XXXX
XX..2
111.2
.X.X2

Constraints: for all testdata, 1≤n≤15001 \leq n \leq 1500, 1≤m≤21 \leq m \leq 2, and the map contains only . and X。

Subtask ID Additional Constraints Points
1 m=1m = 1 20
2 n≤30n \leq 30 22
3 n≤300n \leq 300 23
4 35

Translated by ChatGPT 5