#P4230. 连环病原体
连环病原体
Description
Problem summary:
There are types of pathogens, and there are kinds of undirected influences among them. The -th influence occurs between pathogens and , specifically between two pathogens.
We arrange all the influences in order by their indices to form a sequence. If an interval contains a cycle, then that interval is called a reinforcement interval.
For each influence, count in how many reinforcement intervals it appears.
So, how can we compute the result efficiently?
(For the subsequent story, see the editorial of this problem. Please proceed to T2.)
Input Format
The first line contains a number .
Then lines follow; each line contains two numbers , , separated by a space.
Output Format
Output one line with numbers. The -th number denotes how many reinforcement intervals contain the -th influence. Numbers are separated by spaces.
5
1 2
2 3
3 4
1 4
4 2
2 3 3 3 2
Hint
Sample explanation:
The first influence appears in two reinforcement intervals: [1,4] and [1,5].
The second influence appears in three reinforcement intervals: [1,4], [1,5], and [2,5].
The third influence appears in three reinforcement intervals: [1,5], [1,4], and [2,5].
The fourth influence appears in three reinforcement intervals: [1,4], [2,5], and [1,5].
The fifth influence appears in two reinforcement intervals: [2,5] and [1,5].
Note: reinforcement intervals are formed by “influences” (edges), not by “pathogens” (vertices).
Constraints
Test points 1–2, total 10 points, .
Test points 3–6, total 20 points, .
Test points 7–12, total 30 points, .
Test points 13–15, total 15 points, .
Test points 16–18, total 15 points, , bundled test.
Test points 19–22, total 10 points, , bundled test.
by oscar
Translated by ChatGPT 5
京公网安备 11011102002149号