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:44Karthik 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:440388,782,658376,339,0001,264,0002,113,536expected "83", got "len 100000000 bin 1 b0 0 0 1 1 ones 70262178 best 83 at 715 306 cnt 1 second 82 "
2Oct 3, 2026 03:440394,679,585382,398,0001,084,0002,113,536expected "57", got "len 100000000 bin 1 b0 1 1 1 1 ones 70262623 best 57 at 2827 618 cnt 1 second 56 "
3Oct 3, 2026 03:440391,512,836379,253,0001,067,0002,113,536expected "50", got "len 100000000 bin 1 b0 0 1 1 0 ones 70268333 best 50 at 65 8441 cnt 21 second 49 "