#P2867. [USACO06NOV] Big Square S

    ID: 1910 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 6 上传者: 标签>动态规划,dp2006USACO枚举,暴力深度优先搜索,DFS

[USACO06NOV] Big Square S

Description

Farmer John’s cows are competing against Farmer Bob’s cows.

They draw an N×NN\times N square lattice of points in the field. Each farm’s cows occupy some points, and of course no two cows can be at the same point.

Each farm aims to use its own cows as the 44 vertices to form a square with the maximum possible area (the square does not need to be axis-aligned).

All of John’s cows except Bessie have already been placed on the lattice. Determine where to place Bessie so that John’s farm can obtain a square with the maximum possible area (Bessie is not required to be one of the four vertices).

Input Format

Line 11: A single integer NN (2N1002 \leq N \leq 100).

Lines 22 to (N+1)(N+1): The (i1)(i-1)-th of these lines uses NN characters to describe row ii of the field. J denotes a point occupied by John’s cow, B denotes a point occupied by Bob’s cow, and * denotes an unoccupied point. The input guarantees at least one unoccupied point.

Output Format

Output a single integer, the maximum area that John’s farm can achieve. If no square can be formed, output 00.

6
J*J***
******
J***J*
******
**B***
******
4

Hint

Translated by ChatGPT 5