#D. CS240 project Problem 4

    传统题 1000~10000ms 256~4096MiB

CS240 project Problem 4

该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。

Description

You are asked to hold a conference, the first step of which is to choose the proper dates. The conference must span several consecutive days. Each day, one lecturer is needed to give a presentation, and each lecturer cannot give more than one presentation during the conference. There are nn lecturers that can participate in the conference in total, the ith of whom is available from day lil_i to day rir_i, inclusive of lil_i and rir_i. Several consecutive days can be chosen to hold the conference if there is a way to invite available lecturers to each of the days, without inviting lecturers more than once. For kk from 11 to nn, we want to find out how many ways are there to choose kk consecutive days as the conference dates.

Format

Input

The first line of input contains one integer n, indicating the number of lecturers (1n1×1041 \leq n \leq 1 \times 10^4). Each of the next n lines contains two integers lil_i and rir_i, the ithi_{th} lecturer is available during these days (1liri2×1041 \leq li \leq ri \leq 2 × 10^4).

Output

Print nn lines, the kthk_{th} line contains one integer indicating the number of ways of selecting a conference of kk days.

Samples

3
1 3
2 4
3 6
6
4
3

Explanation

k = 1: all the days are valid, so there are 6 ways. k = 2: [1, 2], [2, 3], [3, 4], [4, 5] are valid, [5, 6] is not valid, so there are 4 ways. k = 3: [1, 3], [2, 4], [3, 5] are valid, 3 ways.

5
1 3
1 3
1 3
1 3
1 3
3
2
1
0
0

Explanation

k = 1: all the days are valid, so there are 6 ways. k = 2: [1, 2], [2, 3], [3, 4], [4, 5] are valid, [5, 6] is not valid, so there are 4 ways. k = 3: [1, 3], [2, 4], [3, 5] are valid, 3 ways.

Limitation

1s, 256MB for test cases with n<100n < 100 10s, 4096MB for the others

CS240 2024 Spring Project Problem

未参加
状态
已结束
规则
IOI
题目
4
开始于
2024-5-30 17:00
结束于
2024-6-24 23:59
持续时间
607 小时
主持人
参赛人数
99