SubTask 1:

Generate all possible sub-squares and look for the optimal one.

Time Complexity: $O(T*(min(N,M)^3)$

SubTask 2:

Generate all possible sub-squares and look for the optimal one. But this time, do this for 2^k times!

Time Complexity: $O(T*2^k*(min(N,M)^3)$

SubTask 3:

Let dp[x][y] be the maximum side length of a square having (x,y) cell as the bottom right corner. You can generate the dp table in $O(NM)$ time .Do this for 2^k times!

Time Complexity: $O(T*2^k*N*M)$

SubTask 4:

Special cells do not matter at all!
Let dp[x][y] be the maximum side length of a square having (x,y) cell as the bottom right corner. Calculate the maximum side length of a square each time and calculate the possible minimum cost of respective square ending at (x,y). You can generate the dp table in $O(NM)$ time .

Time Complexity: $O(T*N*M)$

Statistics

55% Solution Ratio
Tahmid690Earliest, Oct '20
nusuBotFastest, 0.2s
fsshakkhorLightest, 16 MB
Kabir03Shortest, 2243B
Toph uses cookies. By continuing you agree to our Cookie Policy.