2 shunfurh shunfurh 于 2017.01.01 00:44 提问

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 with N × 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

1个回答

devmiao
devmiao   Ds   Rxr 2017.01.03 18:45
已采纳
Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!
其他相关推荐
usaco 5.3 Big Barn(简单DP)
Big Barn A Special Treat 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
poj3251 & usaco 月赛 2006 Big Square 题解
【原题】 Big Square Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 2569   Accepted: 624 Description Farmer John's cows have entered into a competition wi
POJ3251-Big Square (C语言实现)
#include #define SIZE 201 #define INFARM(a, b, c, d)  a > 0 && b > 0 && c > 0 && d > 0 && a #define AREA(a, b)  a * a + b * b int i, j, x, y, length, p, q, max_area; char fa
POJ3251:Big Square 题解
【原题】 Big Square Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 4882   Accepted: 1000 Description Farmer John's cows have entered into a competiti
【枚举】Big Square
问题 2:Big Square(bigsq.pas)   农民 John 的牛参加了一次和农民 Bob 的牛的竞赛。他们在区域中画了一个N*N(2 除了John 的一头牛Bessie以外,John其他的牛都已经放到点阵中去了,要确定Bessie放在哪个位置,能使得农民John的农场得到一个最大的正方形(Bessie不是必须参与作为正方形的四个顶点之一)。   输入格式: Line 1
poj 3251 Big Square
也许你会诧异这题 有啥好写题解的。。?暴力枚举不就完了但是 WA是自己作。没有看到不能平行。。T是真的。。。 O(n^4)怎么破?靠瞎减减呗。这里主要是感叹#define 的 快速。。最后实现的AC就是靠他。define的优缺点优点 提高了程序的可读性,同时也方便进行修改; 提高程序的运行效率:使用带参的宏定义既可完成函数调用的功能,又能避免函数的出栈与入栈操作,减少系统开销,提高运行效率;
MATLAB 中square 的用法
周期性矩形脉冲信号 MATLAB语言调用形式: y=square(t,duty) 产生一个周期为2 π,幅值为±1的周期性方波, duty表示占空比(duty cycle) t=-0.0625:0.0001:0.0625; y=square(2*pi*30*t,75); plot(t,y),grid on axis([-0.1,0.1,-1.5,1.5]) 占空比75% 30指产生30HZ
Codeforces Beta Round #1 A. Theatre Square
从今天开始,就要在Codeforces里有一个新的开始了,貌似任务很重的说~~ Codeforces专题我将会记录所有通过的题目,其实只要通过的题目都是水题啊!! 题目大意: 按照要求计算需要多少flagstone. 下面是代码: #include int main() { long long n,m,a,r,c; scanf("%I64
221. Maximal Square | Java最短代码实现
原题链接:221. Maximal Square 【思路】 本题考查动态规划。我们知道当 maxtrix[i][j] = '1' 时,以 matrix[i][j] 为正方形右下角的边长,最多比以 matrix[i - 1][j]、matrix[i][j - 1]、matrix[i - 1][j - 1] 为右下角的正方形边长大1。如果以 matrix[i - 1][j]、matrix[i][j
matlab中的square函数
square(T)函数产生一个2*pi为周期的方波,范围在-1到1之间,占空比为50%。很像sin函数,比如sin函数输入pi/6 就是1/2,输入pi/2 就是1,输入pi就是0,输入3/2*pi就是-1;而square也是一样,输入的数小于pi,就是1,大于pi小于2*pi就是-1。  square(T, duty), duty是一个百分数,duty = 75(75%的占空比)。如图第一