#C6931. Frequently Used Grid Points
Frequently Used Grid Points
Frequently Used Grid Points
In a 2D grid, there are several train routes running along the grid lines. Each route is either horizontal or vertical and is given by two endpoints (x₁, y₁) and (x₂, y₂). A route covers all the integer points between its endpoints. A grid point is considered frequently used if it is traversed by at least two different routes. In other words, if c(x, y) denotes the number of routes that pass through the point (x, y), then the point is frequently used if \( c(x,y) \ge 2 \).
Your task is to determine the number of unique grid points that are frequently used by the given routes.
Note: For horizontal routes, y₁ equals y₂, and for vertical routes, x₁ equals x₂.
inputFormat
The input is read from standard input (stdin). The first line contains a single integer N, the number of train routes. Each of the next N lines contains four integers: x₁, y₁, x₂, y₂, representing the endpoints of a train route.
N x₁ y₁ x₂ y₂ x₁ y₁ x₂ y₂ ... x₁ y₁ x₂ y₂
outputFormat
Output a single integer to standard output (stdout): the number of unique grid points that are traversed by at least two routes.
## sample5
1 1 1 5
2 3 2 6
1 4 3 4
1 2 4 2
3 3 3 6
4