Well the contest want to do it this way , I mean using 2D array.
But what worries now me is that the 2d array will be 1000x1000 which is a lot
And I am not sure that there is a way to write such thing and make the code to complete the action for 3 seconds