当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

2168:Joke with Turtles

Special Judge 特殊评判
题目描述
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 ai turtles crawling ahead of me and bi 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 xi coordinate. Some turtles may have the same coordinate. Turtle i tells the truth if and only if ai is the number of turtles such that xj > xi and bi is the number of turtles such that xj < xi. Otherwise, turtle i is lying.
输入解释
The first line of the input contains integer number n (1 <= n <= 1000). It is followed by n lines containing numbers ai and bi (0 <= ai, bi <= 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.
输入样例
5
0 2
0 3
2 1
1 2
4 0
输出样例
2 1 4

该题目是Virtual Judge题目,来自 北京大学POJ

源链接: POJ-2168

最后修改于 2020-10-29T06:25:21+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
1000 65536