转载请注明出处:http://blog.csdn.net/RavenChau/article/details/78023318
【原题】
|
Big Square
Description Farmer John's cows have entered into a competition with Farmer Bob's cows. They have drawn lines on the field so it is a square grid withN ×N points (2 ≤ N ≤ 100), and each cow of the two herds has positioned herself exactly on a gridpoint. Of course, no two cows can stand in the same gridpoint. The goal of each herd is to form the largest square (not necessarily parallel to the gridlines) whose corners are formed by cows from that herd. All the cows have been placed except for Farmer John's cow Bessie. Determine the area of the largest square that Farmer John's cows can form once Bessie is placed on the field (the largest square might not necessarily contain Bessie). Input
Line 1: A single integer,
N
Lines 2.. N+1: Line i+1 describes line i of the field with N characters. The characters are: 'J' for a Farmer John cow, 'B' for a Farmer Bob cow, and '*' for an unoccupied square. There will always be at least one unoccupied gridpoint. Output
Line 1: The area of the largest square that Farmer John's cows can form, or 0 if they cannot form any square.
Sample Input 6 J*J*** ****** J***J* ****** **B*** ****** Sample Output 4 Source
【题意】
图中点J可围成正方形的最大面积(可多加一点J,但不能覆盖点B)
【思路】
两两J点连线,判断能否成为正方形的邻边,之后取最大值
【AC代码】
|
本文介绍了一道竞赛编程题目,目标是在一个由 Farmer John 和 Farmer Bob 的奶牛占据的 N×N 网格中找出 Farmer John 的奶牛能形成的最大正方形面积。文章提供了完整的解题思路及 AC 代码。

550

被折叠的 条评论
为什么被折叠?



