CHEFPATH - editorial

i’d be very sad if this was your best submitted code during the contest. change “YES” to “Yes” and “NO” to “No”. :stuck_out_tongue:

Unfortunately, this was.I don’t know how I missed that.

A path is defined as magical if it starts from any of the cell (a,b) of the maze and ends at the cell (c,d) such that the following conditions are satisfied :-

|a - c| + |b - d| = 1
All the cells in the maze are traversed exactly once.
It is allowed to move only in the four directions - up, down, left and right from the current cell.

THIS IS THE CONDITION for magical path
so lets take an eg n=5 , m=5 matrix , can’t we traverse from (1,1) to (5,1) |a - c| + |b - d| = 1 it holds this condition;
then move to (5,2) then move to upward till (1,2) |a - c| + |b - d| = 1 it holds this condition; then again, (1,3) to (5,3)… and so on till we reach (5,5) ;
we literally satisfied all the conditon i.e sum should be =1 , we should traverse all the cell ; and we can either go up, down, left or right from the current cell; so, why there is no magical path???

Can anyone tell me why should ending cell (c, d) be adjacent to starting cell? I am not getting this as it is not mentioned anywhere in problem statement but I don’t know why they have put this statement in editorial.