CF32D.Constellation
普及/提高-
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
A star map in Berland is a checked field n × m squares. In each square there is or there is not a star. The favourite constellation of all Berland's astronomers is the constellation of the Cross. This constellation can be formed by any 5 stars so, that for some integer x (radius of the constellation) the following is true:
- the 2nd is on the same vertical line as the 1st, but x squares up
- the 3rd is on the same vertical line as the 1st, but x squares down
- the 4th is on the same horizontal line as the 1st, but x squares left
- the 5th is on the same horizontal line as the 1st, but x squares right
Such constellations can be very numerous, that's why they are numbered with integers from 1 on the following principle: when two constellations are compared, the one with a smaller radius gets a smaller index; if their radii are equal — the one, whose central star if higher than the central star of the other one; if their central stars are at the same level — the one, whose central star is to the left of the central star of the other one.
Your task is to find the constellation with index k by the given Berland's star map.
伯兰德的星图是一张 n×m 的方格图。每个方格中要么有一颗星,要么没有星。所有伯兰德天文学家最喜爱的星座是“十字星座”。该星座可由任意 5 颗星构成,使得对某个整数 x(该星座的半径),满足以下条件:
- 第 2 颗星与第 1 颗星位于同一竖直线上,但在第 1 颗星正上方 x 格;
- 第 3 颗星与第 1 颗星位于同一竖直线上,但在第 1 颗星正下方 x 格;
- 第 4 颗星与第 1 颗星位于同一水平线上,但在第 1 颗星正左方 x 格;
- 第 5 颗星与第 1 颗星位于同一水平线上,但在第 1 颗星正右方 x 格。
这类星座可能数量极多,因此按如下规则用从 1 开始的整数为其编号:比较两个星座时,半径较小者编号更小;若半径相等,则中心星(即第 1 颗星)行号更小(即位置更高)者编号更小;若中心星行号也相同,则中心星列号更小(即位置更靠左)者编号更小。
你的任务是:给定一张伯兰德星图,找出编号为 k 的星座。
输入格式
The first line contains three integers n, m and k (1 ≤ n, m ≤ 300, 1 ≤ k ≤ 3·107) — height and width of the map and index of the required constellation respectively. The upper-left corner has coordinates (1, 1), and the lower-right — (n, m). Then there follow n lines, m characters each — description of the map. j-th character in i-th line is «*», if there is a star in the corresponding square, and «.» if this square is empty.
第一行包含三个整数 n、m 和 k(1≤n,m≤300,1≤k≤3⋅107),分别表示地图的高度、宽度以及所要求的星座的编号。左上角坐标为 (1,1),右下角坐标为 (n,m)。接下来是 n 行,每行 m 个字符,描述该地图。第 i 行的第 j 个字符为 *,表示对应位置有一颗星;为 .,表示该位置为空。
输出格式
If the number of the constellations is less than k, output -1. Otherwise output 5 lines, two integers each — coordinates of the required constellation. Output the stars in the following order: central, upper, lower, left, right.
如果星座的数量少于 k,则输出 −1。否则输出 5 行,每行两个整数——所求星座的各星坐标。按以下顺序输出各星:中心星、上方星、下方星、左方星、右方星。
输入输出样例
输入#1
5 6 1 ....*. ...*** ....*. ..*... .***..
输出#1
2 5 1 5 3 5 2 4 2 6
输入#2
5 6 2 ....*. ...*** ....*. ..*... .***..
输出#2
-1
输入#3
7 7 2 ...*... ....... ...*... *.***.* ...*... ....... ...*...
输出#3
4 4 1 4 7 4 4 1 4 7
输入解题思路,AI测评打分。不知道怎么写?