CF1921G.Mischievous Shooter

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Once the mischievous and wayward shooter named Shel found himself on a rectangular field of size n×mn \times m , divided into unit squares. Each cell either contains a target or not.

Shel only had a lucky shotgun with him, with which he can shoot in one of the four directions: right-down, left-down, left-up, or right-up. When fired, the shotgun hits all targets in the chosen direction, the Manhattan distance to which does not exceed a fixed constant kk . The Manhattan distance between two points (x1,y1)(x_1, y_1) and (x2,y2)(x_2, y_2) is equal to x1x2+y1y2|x_1 - x_2| + |y_1 - y_2| .

Possible hit areas for k=3k = 3 .Shel's goal is to hit as many targets as possible. Please help him find this value.

输入格式

Each test consists of several test cases. The first line contains a single integer tt ( 1t10001 \le t \le 1000 ) — the number of test cases. Then follows the description of the test cases.

The first line of each test case contains field dimensions nn , mm , and the constant for the shotgun's power kk ( 1n,m,k105,1nm1051 \le n, m, k \le 10^5, 1 \le n \cdot m \le 10^5 ).

Each of the next nn lines contains mm characters — the description of the next field row, where the character '.' means the cell is empty, and the character '#' indicates the presence of a target.

It is guaranteed that the sum of nmn \cdot m over all test cases does not exceed 10510^5 .

输出格式

For each test case, output a single integer on a separate line, which is equal to the maximum possible number of hit targets with one shot.

输入输出样例

  • 输入#1

    4
    3 3 1
    .#.
    ###
    .#.
    2 5 3
    ###..
    ...##
    4 4 2
    ..##
    ###.
    #..#
    ####
    2 1 3
    #
    #

    输出#1

    3
    4
    5
    2

说明/提示

Possible optimal shots for the examples in the statement:

首页