Destroy Cells Lunchtine August 2019

Problem :DESTCELL Problem - CodeChef
CodeChef: Practical coding for everyone
In it for each K Firstly, I saw whether or not it is visited
Then apply condition for i <= n && j <= m
and change i and j accordingly
According to me each loop will take O((m*n)/(k+1))
Can somebody find the reason for TLE
Thanks in advance :slight_smile:

Convert all integer variable to long long int

@anon55659401 will help u.

KARAN Dm me

Firstly, there is no need for that as at max k = 10^6 which is in range
Secondly, I tried it :sweat_smile:

I think its because u are initialising the visited array each time .
Just initialise it one time and mark it unvisited in the loop after counting.

1 Like