Codeforces Round #630 (Div. 2) Problem A (Need help)

Problem: Problem - A - Codeforces

For a problem A, I’m having a hard time understanding it lol. Can somone please elaborate it and the logic behind the solution?

In the editorial it says :

The key observation is x-axis and y-axis is independent in this task as the area is a rectangle. Therefore, we should only consider 1D case

Why should we consider only 1D case because the area is a rectangle? Why can we ignore the other axis? Any kind of help would be appreciated.

It’s not really the best wording. The idea is that the x and y axes are independent of each other, so you can treat them both separately and solve them both like they’re 1D. So if either x or y is impossible, then the whole thing is impossible.

1 Like

So if either x or y is impossible, then the whole thing is impossible.

Oh alright, so that’s what it means. Thanks, will try to code this up now.

To make it more clear, it basically says that you start at a point (x, y) and have to walk a units left, b units right, c units down and d units up.

But, you need to stay inside the rectangle which has coordinates (x1, y1) and (x2, y2). You have to print Yes if there is a possible way, else No.

P.S: If you need help, tag me, and I will give you a stepwise hint :slight_smile:

sure man, will get back to you if I face any issues. :slight_smile:

Had to think this through but finally understood the logic.
My submission: Submission #75610559 - Codeforces

Thanks for helping.

1 Like