#P3875. [TJOI2010] 被污染的河流
[TJOI2010] 被污染的河流
Description
Unfortunately, not long after, some unscrupulous business owners built factories and polluted the rivers. Many residents living by the rivers drank polluted water and became ill. The government sent an investigator, Xiaoqiang (pinyin), to examine the pollution. The geography expert Xiaoqiang acted quickly and soon produced a pollution report. The report lists the polluted river segments. All residents who can fetch water from any such segment may get sick (the endpoints of a segment are ignored). However, Xiaoqiang could not figure out exactly how many communities’ residents would become ill, so he has asked for your help.

Input Format
The first line contains an integer , the number of polluted river segments.
Each of the next lines contains integers , giving the start and end positions of a polluted segment. The two positions on each line are guaranteed to be distinct and satisfy or .
Output Format
Output a single integer , indicating that there are communities whose residents will drink polluted water.
3
1 3 4 3
6 7 6 3
4 6 7 6
16
Hint
- For of the testdata, , .
- For of the testdata, , .
- For of the testdata, , .
Translated by ChatGPT 5
京公网安备 11011102002149号