#abc354c. C - AtCoder Magics

C - AtCoder Magics

Score : 350350 points

问题陈述

高桥有来自卡牌游戏“AtCoder Magics”的NN张卡牌。第ii张卡牌将被称为卡牌ii。每张卡牌有两个参数:力量和成本。卡牌ii的力量为AiA_i,成本为CiC_i

他不喜欢弱的卡牌,所以他将丢弃它们。具体来说,他将重复以下操作,直到无法再执行:

  • 选择两张卡牌xxyy,使得Ax>AyA_x > A_yCx<CyC_x < C_y。丢弃卡牌yy

可以证明,当操作无法再执行时,剩余卡牌的集合是唯一确定的。找出这个卡牌集合。

以上为大语言模型 kimi 翻译,仅供参考。

Problem Statement

Takahashi has NN cards from the card game "AtCoder Magics." The ii-th card will be called card ii. Each card has two parameters: strength and cost. Card ii has a strength of AiA_i and a cost of CiC_i.

He does not like weak cards, so he will discard them. Specifically, he will repeat the following operation until it can no longer be performed:

  • Choose two cards xx and yy such that Ax>AyA_x > A_y and Cx<CyC_x < C_y. Discard card yy.

It can be proved that the set of remaining cards when the operations can no longer be performed is uniquely determined. Find this set of cards.

Constraints

  • 2N2×1052 \leq N \leq 2 \times 10^5
  • 1Ai,Ci1091 \leq A_i, C_i \leq 10^9
  • A1,A2,,ANA_1, A_2, \dots ,A_N are all distinct.
  • C1,C2,,CNC_1, C_2, \dots ,C_N are all distinct.
  • All input values are integers.

Input

The input is given from Standard Input in the following format:

NN

A1A_1 C1C_1

A2A_2 C2C_2

\vdots

ANA_N CNC_N

Output

Let there be mm remaining cards, cards i1,i2,,imi_1, i_2, \dots, i_m, in ascending order. Print these in the following format:

mm

i1i_1 i2i_2 \cdots imi_m

Sample Input 1

3
2 4
1 1
3 2

Sample Output 1

2
2 3

Focusing on cards 11 and 33, we have A1<A3A_1 < A_3 and C1>C3C_1 > C_3, so card 11 can be discarded.

No further operations can be performed. At this point, cards 22 and 33 remain, so print them.

Sample Input 2

5
1 1
10 2
100 3
1000 4
10000 5

Sample Output 2

5
1 2 3 4 5

In this case, no cards can be discarded.

Sample Input 3

6
32 101
65 78
2 29
46 55
103 130
52 40

Sample Output 3

4
2 3 5 6