QOJ.ac

QOJ

حد الوقت: 2.0 s حد الذاكرة: 512 MB مجموع النقاط: 100 قابلة للهجوم ✓

#8315. 糖果广告

الإحصائيات

Ingenious Candy Processing Company (ICPC) 最近推出了一种新糖果。ICPC 计划在市场中心的大屏幕上展示 $n$ 个广告海报,编号为 $1, 2, \dots, n$。屏幕由多个像素组成,每个广告海报占用 $w \times h$ 个像素。具体来说,第 $k$ 个广告海报在第 $l_k$ 天的早上到第 $r_k$ 天的晚上,会占用所有满足 $x_k \le i \le x_k + w - 1$ 且 $y_k \le j \le y_k + h - 1$ 的像素 $(i, j)$。

图片来自 Wikimedia Commons

你是市场中的中间人。你的工作是确定哪些广告海报可以被接受,使得在任何时间点,没有两个广告海报占用同一个像素。ICPC 还额外给了你 $m$ 个请求,其中第 $k$ 个请求规定:如果第 $a_k$ 个广告海报和第 $b_k$ 个广告海报都被拒绝,ICPC 将取消整个交易。

请确定哪些广告海报应该展示,以确保交易不会被取消,或者确定这是不可能的。

输入格式

输入仅包含一组数据。

第一行包含三个整数 $n, w$ 和 $h$ ($1 \le n \le 50\,000, 1 \le w, h \le 2\,000$),分别表示广告海报的数量和每个广告海报的尺寸。

接下来的 $n$ 行中,第 $i$ 行 ($1 \le i \le n$) 包含四个整数 $l_i, r_i, x_i$ 和 $y_i$ ($1 \le l_i \le r_i \le 2\,000, 1 \le x_i, y_i \le 2\,000$),描述第 $i$ 个广告海报。

下一行包含一个整数 $m$ ($0 \le m \le 100\,000$),表示请求的数量。

接下来的 $m$ 行中,第 $i$ 行 ($1 \le i \le m$) 包含两个整数 $a_i$ 和 $b_i$ ($1 \le a_i, b_i \le n, a_i \neq b_i$),描述第 $i$ 个请求。

输出格式

如果无法完成交易,输出一行 "No"。否则,第一行输出 "Yes",第二行输出 $n$ 个数字,表示你找到的方案。如果第 $i$ 个广告海报被接受,第 $i$ 个数字应为 '1';如果被拒绝,则为 '0'。

如果存在多种方案,输出其中任意一种即可。

样例

样例输入 1

2 2 2
1 2 1 1
2 3 2 2
1
1 2

样例输出 1

Yes
10

样例输入 2

3 2 2
1 2 1 1
1 3 1 2
2 3 2 2
3
1 2
2 3
1 3

样例输出 2

No

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.