TopCoder

abcabcabc
有人要寫 p6 嗎 > <

User's AC Ratio

100.0% (4/4)

Submission's AC Ratio

80.0% (4/5)

Tags

Description

給一個 $N \times N$ 的表格,令左上角座標為 $(1, 1)$ 右下角座標為 $(N, N)$,第 $i$ 行第 $j$ 列座標為 $(i, j)$,每個格子上面有一個正整數或是障礙物。

定義一個正方形的分數為:

  • 若存在任何一個障礙物則 $0$ 分
  • 否則為該正方形中所有數字加總

求分數最高的正方形。

Input Format

第一行輸入一個正整數 $N$。
接下來 $N$ 行,第 $i$ 行輸入一個字串 $S$,$S_j$ 代表格子座標為 $(i, j)$ 的分數,若 $S_j$ 為 $0$ 代表這格是障礙物。

  • $1 \leq N \leq 2000$
  • $0 \leq S_j \leq 9$

Output Format

輸出一個整數代表分數最高的正方形的分數。

Sample Input 1

3
111
101
111

Sample Output 1

1

Sample Input 2

3
012
345
678

Sample Output 2

24

Sample Input 3

5
11111
01111
11111
11111
11110

Sample Output 3

16

Sample Input 4

4
7039
7451
7428
3708

Sample Output 4

22

Hints

Problem Source

Subtasks

No. Testdata Range Constraints Score
1 0~3 範例測資。 0
2 4~19 只有 01 兩種字元。 20
3 0~35 無特別限制。 80

Testdata and Limits

No. Time Limit (ms) Memory Limit (VSS, KiB) Output Limit (KiB) Subtasks
0 1000 524288 65536 1 3
1 1000 524288 65536 1 3
2 1000 524288 65536 1 3
3 1000 524288 65536 1 3
4 1000 524288 65536 2 3
5 1000 524288 65536 2 3
6 1000 524288 65536 2 3
7 1000 524288 65536 2 3
8 1000 524288 65536 2 3
9 1000 524288 65536 2 3
10 1000 524288 65536 2 3
11 1000 524288 65536 2 3
12 1000 524288 65536 2 3
13 1000 524288 65536 2 3
14 1000 524288 65536 2 3
15 1000 524288 65536 2 3
16 1000 524288 65536 2 3
17 1000 524288 65536 2 3
18 1000 524288 65536 2 3
19 1000 524288 65536 2 3
20 1000 524288 65536 3
21 1000 524288 65536 3
22 1000 524288 65536 3
23 1000 524288 65536 3
24 1000 524288 65536 3
25 1000 524288 65536 3
26 1000 524288 65536 3
27 1000 524288 65536 3
28 1000 524288 65536 3
29 1000 524288 65536 3
30 1000 524288 65536 3
31 1000 524288 65536 3
32 1000 524288 65536 3
33 1000 524288 65536 3
34 1000 524288 65536 3
35 1000 524288 65536 3