Exam
Time limit5sMemory limit128 MB
Given n equal-size axis-aligned rectangles dropped in order, report the indices of sheets whose interior no later sheet covers.
- Level
Medium6 of 10
- Topics
- Geometry, Intervals, Sorting, Simulation
- Solved
- No attempts yet
Problem
Byteasar has just begun his PhD. He both researches and teaches, and the first semester is over: his students have taken their exam, and now he has to grade it.
Each student handed in one sheet of paper of size millimetres. Following an old departmental tradition, Byteasar gathered every sheet, tossed them all into the air, and let them fall to the floor. To his surprise, each sheet landed with its sides parallel to the walls of his rectangular office. The students whose sheets end up on top pass the exam.
A sheet is on top if none of its interior points is covered by another sheet. In particular, the sides (the boundary) of a sheet may be covered without disqualifying it.
Determine which students passed the exam.
Input
The first line contains three integers , , and (, ): the number of sheets and the dimensions of each sheet in millimetres. Every sheet is a rectangle with sides parallel to the axes.
The next lines describe the sheets in the order they fell to the floor. Each sheet is given by three integers , , (, ). The point is the lower-left corner of the sheet. If the sheet has height and width ; if the sheet has height and width .
Wherever two sheets overlap, the one that fell later lies on top.
Output
On the first line print one integer : the number of sheets whose interior is not covered by any other sheet. On the second line print, in increasing order, the indices of those sheets. Sheets are numbered through in the order they appear in the input.