一、题目
http://codeforces.com/contest/965/problem/B
二、分析
当k = 1时,取第一个’.’的坐标即可 当k > 1时,需要求出每一个点在上下左右四个方向所能到达的最远处,记为up, down, left, right,再取上下方向和左右方向的和的最大值,即 max(0, up down - k) max(0, left right - k)
三、程序
代码语言:javascript复制n, k = map(int, input().split())
a = []
for i in range(n):
a.append(input())
maxans = 0
xans = 0
yans = 0
for i in range(n):
for j in range(n):
curans = 0
up = 0
while up < k and i - up >= 0 and a[i - up][j] == '.':
up = 1
down = 0
while down < k and i down < n and a[i down][j] == '.':
down = 1
curans = max(0, down up - k)
if k != 1:
left = 0
while left < k and j - left >= 0 and a[i][j - left] == '.':
left = 1
right = 0
while right < k and j right < n and a[i][j right] == '.':
right = 1
curans = max(0, right left - k)
if curans > maxans:
maxans = curans
xans = i
yans = j
print(xans 1, yans 1)