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:47Karthik 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:470676,542,796664,884,0001,003,0002,113,536expected "50", got "A50 n221 84x112 72x119 62x81 61x99 58x83 50x73 50x75 50x79 50x78 50x75 50x73 50x74 50x83 50x69 "
2Oct 3, 2026 03:470677,236,142664,949,0001,005,0002,113,536expected "99", got "A99 n235 99x133 62x120 61x114 56x135 52x122 50x75 50x70 50x76 50x78 50x77 50x73 50x82 50x73 50x71 "
3Oct 3, 2026 03:470677,242,452664,754,0001,263,0002,117,632expected "50", got "A50 n243 80x105 70x84 55x125 50x70 50x70 50x81 50x70 50x83 50x74 50x71 50x133 50x70 50x73 50x74 "