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 05:54Karthik 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 05:550489,362,248456,126,00022,541,0002,113,536expected "89", got "A89 h21,15,18,22,21,14,17,19,15,23,16 big1 89@5789,5161 "
2Oct 3, 2026 05:550488,610,088455,333,00022,747,0002,113,536expected "85", got "A85 h21,24,23,20,20,15,20,33,22,18,24 big1 85@4877,573 "
3Oct 3, 2026 05:550491,369,633456,281,00022,819,0002,113,536expected "50", got "A50 h25,27,23,10,22,25,22,14,23,20,23 big0 "