CF965B.Battleship
普及-
通过率:0%
时间限制:1.50s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Arkady is playing Battleship. The rules of this game aren't really important.
There is a field of n×n cells. There should be exactly one k-decker on the field, i. e. a ship that is k cells long oriented either horizontally or vertically. However, Arkady doesn't know where it is located. For each cell Arkady knows if it is definitely empty or can contain a part of the ship.
Consider all possible locations of the ship. Find such a cell that belongs to the maximum possible number of different locations of the ship.
阿尔卡季正在玩“战舰”游戏。本题中游戏的具体规则并不重要。
有一个 n×n 的方格棋盘。棋盘上应当恰好放置一艘长度为 k 的舰船(即“k-连舰”),该舰船水平或垂直放置,占据 k 个连续的格子。然而,阿尔卡季并不知道舰船的确切位置。对于每个格子,阿尔卡季仅知道它必定为空,或可能包含舰船的一部分。
考虑舰船所有可能的合法放置位置(即所有满足方向、长度、完全落在棋盘内、且所占全部 k 个格子均非“必定为空”的位置)。请找出一个格子,使得它被最多数量的不同舰船位置所覆盖(即属于最多可能的舰船放置方案)。
输入格式
The first line contains two integers n and k (1≤k≤n≤100) — the size of the field and the size of the ship.
The next n lines contain the field. Each line contains n characters, each of which is either '#' (denotes a definitely empty cell) or '.' (denotes a cell that can belong to the ship).
第一行包含两个整数 n 和 k(1≤k≤n≤100)—— 分别表示棋盘的大小和舰船的大小。
接下来的 n 行描述棋盘。每行包含 n 个字符,每个字符为 '#'(表示该格子必定为空)或 '.'(表示该格子可能属于舰船)。
输出格式
Output two integers — the row and the column of a cell that belongs to the maximum possible number of different locations of the ship.
If there are multiple answers, output any of them. In particular, if no ship can be placed on the field, you can output any cell.
输出两个整数——分别表示属于最多可能的不同舰船位置的单元格所在的行号和列号。
如果存在多个满足条件的答案,输出任意一个即可。特别地,若舰船无法放置在该棋盘上,则可输出任意一个单元格。
输入输出样例
输入#1
4 3 #..# #.#. .... .###
输出#1
3 2
输入#2
10 4 #....##... .#...#.... ..#..#..#. ...#.#.... .#..##.#.. .....#...# ...#.##... .#...#.#.. .....#..#. ...#.#...#
输出#2
6 1
输入#3
19 6 ##..............### #......#####.....## .....#########..... ....###########.... ...#############... ..###############.. .#################. .#################. .#################. .#################. #####....##....#### ####............### ####............### #####...####...#### .#####..####..##### ...###........###.. ....###########.... .........##........ #.................#
输出#3
1 8
说明/提示
The picture below shows the three possible locations of the ship that contain the cell (3,2) in the first sample.

下图展示了第一个样例中包含单元格 (3,2) 的船的三种可能位置。

输入解题思路,AI测评打分。不知道怎么写?