logo AlgoBeat OnlineJudge
登录 注册

#215199. [UOI 2023 II Stage] Rectangles are everywhere

内存限制:512 MiB 时间限制:1000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

Andriyko drank a lot of compote and now he's very afraid of rectangles. Andriyko's room can be mathematically represented as a rectangle with height and width . In this room, there are rectangles, each of which is completely inside the room and does not touch the points and (where is the top-left and is the bottom-right point).

Andriyko wants to go from the corner to without ever touching any of the rectangles (not even touching them). If he is at coordinate , then he can move to any of the following coordinates with one step: , , , , but only if the next coordinate does not go beyond the boundaries of the rectangle.

Determine if he can reach from one corner to the other.

输入格式

The first line contains three integers , , .

Each of the next lines contains four integers , , , --- the coordinates of the top-left and bottom-right corners of rectangle .

It is guaranteed that no rectangle touches the points and .

输出格式

Print if Andriyko can travel between the ends of the room, and otherwise.

样例

样例输入 1

3 4 3
0 2 1 4
1 2 3 3
2 1 3 3

样例输出 1

NO

样例输入 2

3 4 3
0 2 1 4
1 0 2 1
2 1 3 3

样例输出 2

YES

数据范围与提示

  • ( points):
  • ( points):
  • ( points):
  • ( points):
  • ( points):
  • ( points):
  • ( points): no additional constraints.