#P7992. [USACO21DEC] Convoluted Intervals S
[USACO21DEC] Convoluted Intervals S
Problem Description
The cows are trying hard to invent fun new games to play. One of their current projects involves a set of intervals (), where the -th interval starts at position on the number line and ends at position . Both and are integers in the range , where .
The game is played as follows: Bessie chooses an interval (suppose it is the -th interval), and her cousin Elsie chooses an interval (suppose it is the -th interval, which may be the same as Bessie's). Given a value , they win if .
For each value in the range , compute the number of ordered pairs such that Bessie and Elsie can win the game.
Input Format
The first line of input contains and . The next lines each describe an interval as integers and .
Output Format
Output lines. In order, each line should contain the answer for each in the range .
2 5
1 3
2 5
0
0
1
3
4
4
4
3
3
1
1
Hint
[Sample Explanation]
In this example, for , there are three ordered pairs that allow Bessie and Elsie to win: , , and .
[Constraints]
- Test cases 1-2 satisfy .
- Test cases 3-5 satisfy .
- Test cases 6-20 have no additional constraints.
Translated by ChatGPT 5