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 listJan 4, 2026 18:01Josu San MartinJosu San MartinError
Source Code

Source code access is restricted. Log in to request access.

Challenge History
DateChallengerCostTypeStatus
Sep 4, 2026 17:21Victor Mercklé10.00CustomSolution Broken
Jul 5, 2026 23:29Victor Mercklé10.00CustomSolution Held
Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 4, 2026 17:4109,223,4841,153,00002,117,632expected "2", got "50 "
2Sep 4, 2026 17:4109,978,3991,143,00002,117,632expected "2", got "50 "
3Sep 4, 2026 17:4109,272,1161,154,00002,117,632expected "2", got "50 "
4Jan 4, 2026 18:123,80821,955,6781,523,00002,445,312
5Jan 4, 2026 18:123,87017,462,8321,548,00002,449,408
6Jan 5, 2026 02:313,90516,299,2961,562,00002,441,216
7Jan 4, 2026 18:123,94821,038,7831,579,00002,449,408
8Jan 4, 2026 18:134,00817,702,1921,603,00002,445,312
9Jan 4, 2026 18:134,02516,551,3031,610,00002,535,424
10Jan 5, 2026 02:314,09813,029,3211,639,00002,441,216
11Jan 5, 2026 02:314,10816,992,4581,643,00002,449,408
12Jan 4, 2026 18:014,12515,665,8001,650,00002,535,424
13Jan 4, 2026 18:014,13016,982,6201,652,00002,437,120
14Jan 4, 2026 18:014,16021,999,05701,664,0002,441,216
15Jan 4, 2026 18:134,31523,876,1231,726,00002,441,216