Logo
(追記) (追記ここまで)

7394번 - Joke with Turtles 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 128 MB322100.000%

문제

There is a famous joke-riddle for children:

Three turtles are crawling along a road. One turtle says: "There are two turtles ahead of me." The other turtle says: "There are two turtles behind me." The third turtle says: "There are two turtles ahead of me and two turtles behind me." How could this have happened?

The answer is --- the third turtle is lying!

Now in this problem you have $n$ turtles crawling along a road. Some of them are crawling in a group, so that they do not see members of their group neither ahead nor behind them. Each turtle makes a statement of the form: "There are $a_i$ turtles crawling ahead of me and $b_i$ turtles crawling behind me." Your task is to find the minimal number of turtles that must be lying.

Let us formalize this task. Turtle $i$ has $x_i$ coordinate. Some turtles may have the same coordinate. Turtle $i$ tells the truth if and only if $a_i$ is the number of turtles such that $x_j>x_i$ and $b_i$ is the number of turtles such that $x_j<x_i$. Otherwise, turtle $i$ is lying.

입력

The first line of the input file contains integer number $n$ (1ドル \le n \le 1000$). It is followed by $n$ lines containing numbers $a_i$ and $b_i$ (0ドル \le a_i, b_i \le 1000$) that describe statements of each turtle for $i$ from 1 to $n$.

출력

On the first line of the output file write an integer number $m$ --- the minimal number of turtles that must be lying, followed by $m$ integers --- turtles that are lying. Turtles can be printed in any order. If there are different sets of $m$ lying turtles, then print any of them.

제한

예제 입력 1

3
2 0
0 2
2 2

예제 출력 1

1 3

예제 입력 2

5
0 2
0 3
2 1
1 2
4 0

예제 출력 2

2 1 4

힌트

출처

ICPC > Regionals > Northern Eurasia > Northern Eurasia Finals > NEERC 2004 J번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /