CF31C.Schedule

普及+/提高

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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.

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.

新学期伊始,伯兰国立大学制定了新的课程表。根据该课程表,共有 nn 个班级在 31 号教室上课。对于每个班级,其课程的开始时间与结束时间均已知。结果发现,并非所有课程都能如期举行,因为部分班级的上课时段存在交叠。若某一时刻,一个班级的课程恰好结束,而另一班级的课程恰好开始,则这两个课程时段不视为交叠。

教务长希望取消某一个班级的课程,使得其余所有班级的课程时段两两之间均无交叠。你需要找出所有可行的取消方案。

输入格式

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 ≤ 106) — starting and finishing times of lesson of the i-th group. It is possible that initially no two lessons intersect (see sample 1).

第一行包含一个整数 nn(1≤n≤50001 \leq n \leq 5000)—— 在 31 号教室上课的小组数量。接下来有 nn 行,每行包含两个整数 lil_i、rir_i(1≤li<ri≤1061 \leq l_i < r_i \leq 10^6)—— 第 ii 个小组课程的开始时间和结束时间。初始时,任意两门课程可能互不相交(参见样例 1)。

输出格式

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.

输出整数 kk —— 表示恰好取消一个组的课程,使得剩余各组的课程时间区间互不相交的方案数。
第二行输出 kk 个整数 —— 表示可以取消课程的组的编号(按输入中给出的顺序从 1 开始编号)。请将这些编号按升序输出。

输入输出样例

  • 输入#1

    3
    3 10
    20 30
    1 3

    输出#1

    3
    1 2 3
  • 输入#2

    4
    3 10
    20 30
    1 3
    1 39

    输出#2

    1
    4
  • 输入#3

    3
    1 5
    2 6
    3 7

    输出#3

    0

输入解题思路,AI测评打分。不知道怎么写?

首页