日程安排AI (CI翻译)
At the beginning of the new semester there is new schedule in the Berland State University. According to this schedule, $*n*$ groups have lessons at the room 31. For each group the starting time of the lesson and the finishing time of the lesson are known. It has turned out that it is impossible to hold all lessons, because for some groups periods of their lessons intersect. If at some moment of time one groups finishes it's lesson, and the other group starts the lesson, their lessons don't intersect.
在新学期开始时,贝尔兰国立大学启用了新的课表。根据这份课表,$*n*$ 个小组需要在 31 号教室上课。对于每个小组,我们都知道课程的开始时间和结束时间。后来发现无法安排所有课程,因为有些小组的上课时间段相互重叠。如果在某个时刻,一个小组结束课程,而另一个小组开始课程,那么它们的课程不算重叠。AI (CI翻译)
The dean wants to cancel the lesson in one group so that no two time periods of lessons of the remaining groups intersect. You are to find all ways to do that.
院长希望取消其中一个小组的课程,使剩余小组中任意两个课程的时间段都不重叠。请找出所有可行的取消方案。AI (CI翻译)
Input
输入格式
AI (CI翻译)The first line contains integer $*n*$ ($1 ≤ *n* ≤ 5000$) — amount of groups, which have lessons in the room 31. Then $*n*$ lines follow, each of them contains two integers $*l*_{*i*}$ $*r*_{*i*}$ ($1 ≤ *l*_{*i*} < *r*_{*i*} ≤ 10^{6}$) — starting and finishing times of lesson of the $*i*$-th group. It is possible that initially no two lessons intersect (see sample 1).
第一行包含一个整数 $*n*$($1 ≤ *n* ≤ 5000$)——需要在 31 号教室上课的小组数量。接下来 $*n*$ 行,每行包含两个整数 $*l*_{*i*}$ $*r*_{*i*}$($1 ≤ *l*_{*i*} < *r*_{*i*} ≤ 10^{6}$)——第 $*i*$ 个小组课程的开始时间和结束时间。初始时可能不存在任何两个课程相互重叠的情况(见样例 1)。AI (CI翻译)
Output
输出格式
AI (CI翻译)Output integer $*k*$ — amount of ways to cancel the lesson in exactly one group so that no two time periods of lessons of the remaining groups intersect. In the second line output $*k*$ numbers — indexes of groups, where it is possible to cancel the lesson. Groups are numbered starting from $1$ in the order that they were given in the input. Output the numbers in increasing order.
输出一个整数 $*k*$——恰好取消一个小组的课程后,使剩余小组中任意两个课程的时间段都不重叠的方案数。第二行输出 $*k*$ 个整数——可以取消课程的小组编号。小组按照它们在输入中出现的顺序从 $1$ 开始编号。请按递增顺序输出这些编号。AI (CI翻译)
样例
3
3 10
20 30
1 3
3
1 2 3
4
3 10
20 30
1 3
1 39
1
4
3
1 5
2 6
3 7
0
题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(gpt-6.1-sol),如有出入请以原文为准。