Codeforces Round 211 (Div. 2)
E
Two Circles
Codeforces
2500
原题
← D→
翻译中…

Let's assume that we are given an $*n* × *m*$ table filled by integers. We'll mark a cell in the $*i*$-th row and $*j*$-th column as $(*i*, *j*)$. Thus, $(1, 1)$ is the upper left cell of the table and $(*n*, *m*)$ is the lower right cell. We'll assume that a circle of radius $*r*$ with the center in cell $(*i*_{0}, *j*_{0})$ is a set of such cells $(*i*, *j*)$ that image. We'll consider only the circles that do not go beyond the limits of the table, that is, for which $*r* + 1 ≤ *i*_{0} ≤ *n* - *r*$ and $*r* + 1 ≤ *j*_{0} ≤ *m* - *r*$.

翻译中…

image A circle of radius 3 with the center at $(4, 5)$.

翻译中…

Find two such non-intersecting circles of the given radius $*r*$ that the sum of numbers in the cells that belong to these circles is maximum. Two circles intersect if there is a cell that belongs to both circles. As there can be more than one way to choose a pair of circles with the maximum sum, we will also be interested in the number of such pairs. Calculate the number of unordered pairs of circles, for instance, a pair of circles of radius 2 with centers at $(3, 4)$ and $(7, 7)$ is the same pair as the pair of circles of radius 2 with centers at $(7, 7)$ and $(3, 4)$.

翻译中…

Input

翻译中…

The first line contains three integers $*n*$, $*m*$ and $*r*$ ($2 ≤ *n*, *m* ≤ 500$, $*r* ≥ 0$). Each of the following $*n*$ lines contains $*m*$ integers from 1 to 1000 each — the elements of the table. The rows of the table are listed from top to bottom at the elements in the rows are listed from left to right. It is guaranteed that there is at least one circle of radius $*r*$, not going beyond the table limits.

翻译中…

Output

翻译中…

Print two integers — the maximum sum of numbers in the cells that are located into two non-intersecting circles and the number of pairs of non-intersecting circles with the maximum sum. If there isn't a single pair of non-intersecting circles, print 0 0.

翻译中…

样例

Input #1
2 2 0
1 2
2 4
Output #1
6 2
InputCopy OutputCopy
Input #2
5 6 1
4 2 1 3 2 6
2 3 2 4 7 2
5 2 2 1 1 3
1 4 3 3 6 4
5 1 4 2 3 2
Output #2
34 3
InputCopy OutputCopy
Input #3
3 3 1
1 2 3
4 5 6
7 8 9
Output #3
0 0
InputCopy OutputCopy
题目信息
题号
363E
时间限制
4 s
内存限制
256 MB
标签
暴力
数据结构
模拟

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。