eolymp
bolt
Try our new interface for solving problems
Problems

Chords

Chords

Consider a circle. There are \textbf{2N} different points marked on it and numbered with integer numbers in range from \textbf{1} to \textbf{N} so that each number from the interval has two points corresponding to it. Points with the same numbers are connected by segments. Thus we’ve got \textbf{N} chords. Futhermore, the chords are numbered as well: the chord number "\textbf{i}" connects the two different points with number "\textbf{i}". Apparently some of the chords may intersect. Now it would be nice to find out for each single chord the number of chords it intersects. \InputFile In the first line of the input file there is a single integer number \textbf{N} (\textbf{1} ≤ \textbf{N} ≤ \textbf{10^5}). In the next line there are \textbf{2N} integers in range from \textbf{1} to \textbf{N} - the numbers assigned to the points in the order of traversal. Each number is written exactly twice. All the numbers in the line are separated with spaces. \OutputFile The output file is supposed to contain exactly \textbf{N} lines: on the \textbf{i}-th line write the number of chords that \textbf{i}-th chord intersects.
Time limit 1 second
Memory limit 256 MiB
Input example #1
5
2 4 5 3 2 5 3 1 1 4 
Output example #1
0
3
2
1
2