I am not Getting The Solution Of This Problem? Please Help!

I have tried a lot to understand this problem from tutorials on codeforces but not getting, how to solve it? please help…
[Problem - 1030B - Codeforces]

So, do you know how to find, whether two points are on the same or opposite side of a line when the equation of a line and the two points are given? This is what happening here with four lines.
This is my solution.

1 Like

You are given the points- (0,d) , (d,0) ,(n,n-d) ,(n-d,n). So you can easily find the equation of the lines through the points

  1. x+y=d
  2. x+y=2n-d
  3. x+(-y)=d
  4. x-y=-d
    So, if the given points need to be inside the points, they must either lie inside the area covered by these equations.
    So you just need to just where the given points ai, bi lies from d to 2*n-d and x-y lies from -d to d
1 Like

Thanks a lot bro

Thanks a lot sir,got your solution