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

[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 (m2)(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, 1n15001 \leq n \leq 1500, 1m21 \leq m \leq 2, and the map contains only . and X

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

Translated by ChatGPT 5