Largest Square Submatrix of all 1's Haha Expert

Find the largest square submatrix consisting entirely of 1s as fast as possible.

Input

A 10,000 x 10,000 matrix of uint8 values (0 or 1) on STDIN.

0, 1, 0, 1, 1
0, 1, 1, 1, 1
0, 0, 1, 0, 0
1, 0, 1, 1, 0

Output

Print the side length of the largest all-ones square submatrix to STDOUT. The answer is guaranteed to be greater than 1.

For the example above, the output is:

2
Back to listOct 3, 2026 03:45Karthik ReddyKarthik ReddyError
Source Code

Source code access is restricted. Log in to request access.

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Oct 3, 2026 03:450688,208,282676,622,0001,003,0002,113,536expected "50", got "A50 n2071 bg29 [4 52 2791 2861] [11 11 6940 6970] [19 19 1145 1175] [23 23 5534 5566] [25 26 5525 5566] [31 33 5533 5568] [33 33 721 753] [35 38 5526 5568] "
2Oct 3, 2026 03:450688,107,828676,505,0001,001,0002,117,632expected "50", got "A50 n2042 bg29 [1 1 5169 5200] [1 1 5708 5738] [6 6 3585 3615] [17 17 3590 3620] [17 17 8123 8155] [23 23 3588 3621] [49 49 4354 4384] [50 50 564 595] "
3Oct 3, 2026 03:450689,184,451677,585,0001,001,0002,113,536expected "50", got "A50 n2008 bg29 [0 39 7142 7204] [7 55 3964 4042] [19 63 2567 2629] [41 80 1183 1244] [41 41 2764 2799] [47 47 4938 4976] [52 94 7810 7880] [57 57 9747 9779] "