eolymp
bolt
Спробуйте наш новий інтерфейс для відправки розв'язків
Задачі

Friendly Points

Friendly Points

Consider \textbf{n} distinct points on a plane. Two points from that set are said to be \textit{friends}, when there exists a rectangle with sides parallel to coordinate axes that contains those two points and doesn’t contain any other point from the given set. A rectangle is said to \textit{contain} a point if the point lies within the rectangle or on its border. How many pairs of friends are there among the given points? \InputFile The first line of the input file contains an integer \textbf{n}, \textbf{1} ≤ \textbf{n} ≤ \textbf{100000}. The next \textbf{n} lines contain two integers each, the coordinates of the given points. The coordinates don’t exceed \textbf{10^9} by absolute value. \OutputFile Output one integer number --- the sought number of pairs of friends.
Ліміт часу 12 секунд
Ліміт використання пам'яті 256 MiB
Вхідні дані #1
5
0 0
0 2
2 0
2 2
1 1
Вихідні дані #1
8
Автор Петро Мітрічев
Джерело Зимова Школа, Харків 2011, День 8