Code not working on spoj- wrong answer

Please check my code and let me know the problem.
https://ide.codingblocks.com/s/483877.

hello @abhi_11

in ur memse function u should u sizeof function the the third argumentr.

lengt5h of array is not equal to the memory occupied by array

I don’t want to memset the whole arr as it is a big size and I might get TLE. Hence clearing only part of the arr used which is equal to the number of tower

I don’t think this is the reason for not getting accepted on spoj. Which case is not handled or mishadled ?

here
memset(x,0,towers);
memset(y,0,towers);

third argument should size in bytes and not the lenght

Changed the same to below but still not accepted

memset(x,0,sizeof(int) *towers); memset(y,0,sizeof(int)*towers); Let me know why it is not getting accepted @spoj

third arg - sizeof(int)*towers

u missed one case as well.

ie gap between 0 to x[0] and 0 to y[0]

Thanks, got it. Changed it and worked on got accepted on spoj. I have one more doubt why during calculation of dist between last tower and the end of the grid (width) we have not considered (width-1))

we dont have tower the end of grid that why not subtracting 1

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.