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: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 03:540682,944,499670,334,0001,249,0002,113,536expected "98", got "A98 n219 h50:20 w23-50 o199 w50:0 h1073741824-0 x 48x48 48x48 40x40 41x41 48x48 46x46 42x42 41x41 49x49 45x45 43x43 42x42 48x48 43x43 46x46 41x41 "
2Oct 3, 2026 03:540682,296,560670,601,0001,014,0002,113,536expected "89", got "A89 n234 h50:24 w50-50 o210 w50:0 h1073741824-0 x 44x44 44x44 43x43 49x49 41x41 48x48 46x46 43x43 47x47 42x42 46x46 45x45 45x45 30x39 48x48 45x45 "
3Oct 3, 2026 03:540681,621,871669,371,0001,003,0002,117,632expected "50", got "A50 n238 h50:23 w18-50 o215 w50:0 h1073741824-0 x 46x46 40x40 40x40 45x45 40x40 47x47 49x49 45x45 42x42 43x43 43x43 46x46 40x40 48x48 45x45 47x47 "