First
time I have tried to solve this with O(n^5) time and got TLE.
Then I have solved this problem in O(n^4) time and got AC. For
O(n^4), when I get input just add the row one after
another. I want to mean that all the elements of the position
a[i][j] =
.
Then I use a brute frost approach to find the result. But I
found in Steven Halim's Websites that this problem can be solved
with O(n^3). I do not know how it can be solved in O(n^3) and I
have not found any notification about this there.
|