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:46Karthik 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:470677,015,638664,786,0001,001,0002,113,536expected "50", got "A50 n215 87x101 71x123 77x68 53x101 50x71 50x68 50x70 50x85 50x73 50x72 50x76 50x75 49x69 49x73 "
2Oct 3, 2026 03:470677,403,378665,187,0001,023,0002,117,632expected "50", got "A50 n243 67x97 60x88 51x81 50x76 50x79 50x73 50x83 50x82 50x74 50x131 50x72 50x75 50x71 50x79 "
3Oct 3, 2026 03:470676,532,311664,830,0001,003,0002,113,536expected "86", got "A86 n241 91x87 86x112 84x87 67x90 62x104 56x93 50x72 50x68 50x71 50x77 50x74 50x83 50x84 50x67 "