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:59Karthik 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:59013,824,6111,512,0001,185,0002,121,728expected "63", got "scan 12/768:582 8/640:529 12/1024:530 10/768:506 16/768:517 12/512:484 nr605 "
2Oct 3, 2026 04:59013,220,2871,526,0001,175,0002,121,728expected "50", got "scan 12/768:559 8/640:529 12/1024:538 10/768:507 16/768:516 12/512:479 nr700 "
3Oct 3, 2026 04:59013,297,2511,545,0001,182,0002,121,728expected "86", got "scan 12/768:559 8/640:532 12/1024:538 10/768:509 16/768:542 12/512:480 nr580 "