QOJ.ac

QOJ

時間限制: 1.0 s 記憶體限制: 256 MB 總分: 100 可 Hack ✓

#9671. 集装箱调度

统计

在繁忙的港口,每天都有大量的集装箱需要堆放在货船的甲板上。为了方便起见,你可以将甲板和集装箱都视为平行于坐标轴的矩形。甲板是一个巨大的矩形区域,其左下角位于 $(0, 0)$,右上角位于 $(l, h)$。

你是一名集装箱调度员,需要安排每个集装箱在甲板上的位置。理论上,你需要合理地进行调度以最大化空间利用率。然而,你觉得自己的薪水太低,所以你想在调度方法上偷懒。你提供的调度方法如下:

  • 由于高度限制,集装箱只能单层堆放,且不能重叠。
  • 由于没有预算购买旋转起重机,集装箱在放置时不能旋转。
  • 集装箱遵循先到先得的原则,这意味着排在前面的集装箱先放置,排在后面的后放置,且不能改变集装箱的顺序。如果某个集装箱在放置过程中无法放下,则将其丢弃。
  • 在选择放置集装箱的位置时,优先选择能够容纳该集装箱且 $x$ 坐标最小的位置。如果有多个候选位置,则选择 $y$ 坐标最小的位置。

总共有 $n$ 个集装箱,每个集装箱沿 $x$ 轴的长度和沿 $y$ 轴的宽度按顺序给出。你的任务是确定每个集装箱是否可以被放置,如果可以,请提供其左下角的坐标。

输入格式

第一行包含三个整数 $n, l, h$ ($1 \le n \le 50, 1 \le l, h \le 10^9$),分别表示集装箱的数量以及甲板区域的长度和宽度。

接下来的 $n$ 行,每行包含两个整数 $x, y$ ($1 \le x, y \le 10^9$),分别表示每个集装箱沿 $x$ 轴的长度和沿 $y$ 轴的宽度。

输出格式

对于每个集装箱,按顺序输出其左下角的坐标(用空格分隔),如果该集装箱可以被放置。否则,输出 $-1$。

样例

样例输入 1

4 10 10
5 5
6 6
4 7
10 2

样例输出 1

0 0
-1
5 0
0 7

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.