#P2448. 无尽的生命
无尽的生命
Description
Time flows on like this, never stopping day or night!
Ye Liangchen (叶良辰) believes his lifespan is infinite, and he improves every day.
On the first day of Ye Liangchen’s life, he has point of ability. On the second day, he has points. On day , he has points. That is, .
However, the mischievous Xiao A (小 A) uses a time machine and tells him that on day and day , he can arbitrarily swap the ability values of any two days, i.e., .
Xiao A plays and plays, and finally gets bored.
Ye Liangchen: Xiao A, just you wait. I have ways to make you wish you were dead. Unless you can tell me within second how many pairs are “abnormal pairs.” That is, in the final ability sequence, how many pairs of days with satisfy ?
Xiao A: I’m so scared.
So he comes to you.
Input Format
The first line contains an integer , indicating how many times Xiao A used the time machine.
The next lines each contain , meaning and are swapped.
Output Format
Output a single line: the number of “abnormal pairs.”
2
4 2
1 4
4
Hint
Sample explanation
- Initially it is .
- Then it becomes .
- Then it becomes .
The matching pairs are , , , .
Constraints
- For of the testdata, .
- For of the testdata, .
- For of the testdata, , .
Translated by ChatGPT 5
京公网安备 11011102002149号