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 04:58Karthik 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 04:58013,201,6531,498,0001,182,0002,121,728expected "50", got "scan 8/640:559 16/640:537 4/1024:523 8/1024:515 16/384:502 12/768:483 nr712 "
2Oct 3, 2026 04:58013,189,5751,510,0001,165,0002,121,728expected "69", got "scan 8/640:543 16/640:537 4/1024:532 8/1024:533 16/384:496 12/768:481 nr618 "
3Oct 3, 2026 04:58013,291,2101,459,0001,184,0002,121,728expected "50", got "scan 8/640:592 16/640:560 4/1024:535 8/1024:512 16/384:552 12/768:485 nr688 "