Problem E

Statement
Copy Copied
Description:
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 (i0, j0) is a set of such cells (i, j) that $$\sqrt{(i-i_{0})^{2}+(j-j_{0})^{2}} \leq r$$. We'll consider only the circles that do not go beyond the limits of the table, that is, for which r + 1 ≤ i0 ≤ n - r and r + 1 ≤ j0 ≤ m - r.

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 Format:
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 Format:
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.

Note:
None

Submissions

IDLanguageExit CodeTimestampCodeStdoutStderrRetry
4991 cpp 0 2026-03-07T10:59:26.126888Z View View View Retry
4988 cpp 1 2026-03-07T10:50:19.13298Z View View View Retry
4985 cpp 1 2026-03-07T10:44:15.840676Z View View View Retry
4984 cpp 1 2026-03-07T10:43:30.082778Z View View View Retry
4982 cpp 1 2026-03-07T10:37:24.008673Z View View View Retry
4981 cpp 1 2026-03-07T10:34:43.840128Z View View View Retry
4976 cpp 1 2026-03-07T10:26:39.176307Z View View View Retry
4968 cpp 1 2026-03-07T10:13:23.486006Z View View View Retry

Evaluations

Eval IDRun IDProviderModelLangSuccessTimestampPromptResponseStdoutStderrRetry
2465 20260314-020010 gemini gemini-3-pro-preview go true 2026-03-14T02:47:04.696735Z View View View View Retry
2164 20260311-031437 gemini gemini-3-pro-preview go true 2026-03-11T04:01:03.61262Z View View View View Retry
1710 20260307-080824 gemini gemini-3-pro-preview go false 2026-03-07T09:44:01.381416Z View View View View Retry