QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 128 MB Total points: 100

#12295. Exam

統計

Byteasar has recently started his PhD studies. He researches and teaches. The first semester is over. Students wrote their exam and now Byteasar has to grade it.

Each student produced one sheet of size $A \times B$ millimetres. According to the advice by his elder colleagues Byteasar applied the standard university procedure. He grabbed all the sheets and threw them to the air. The sheets fell onto the ground. To his surprise, the sheets arranged themselves parallel to the walls of his rectangular office. The exam will be passed by the students whose sheets are on the top.

A sheet is on the top if none of its inner points is covered by another sheet. In particular, this means that sides of the sheet may be covered.

Write a program to check who passed the exam.

Input Format

The first line of input contains three integers $n$, $A$ and $B$ ($1 ≤ n ≤ 100,000$, $1 ≤ A, B ≤ 10^{9}$) denoting respectively the number of sheets and the dimensions of each sheet in millimetres. Sheets are rectangles with sides parallel to the axes.

The following n lines describe sheets in order of their fall to the floor. The description of one sheet is composed of three integers $x_{i}$, $y_{i}$, $r_{i}$ ($-10^{9} ≤ x_{i}, y_{i} ≤ 10^{9}$, $r_{i} \in \{0, 1\}$). Point $(x_{i}, y_{i})$ is the lower left corner of the sheet. If $r_{i} = 0$, then the sheet is a rectangle of height $A$ and width $B$, but when $r_{i} = 1$, the height is $B$ and width $A$.

Output Format

The first line of the output should contain one integer $k$ equal to the number of sheets that are not covered (except for their sides) by other sheets. The second line should hold a sequence numbers of those sheets in increasing order. The sheets are numbered $1$ through $n$ as they appear in the input.

Example

Input

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

Output

2
1 4
About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.