There are two roads: One is straight, and the other...
Limits: 2 sec., 256 MiB
This statement was translated automatically from Ukrainian.
All day long, the members of the election commission are bored, observing the elections, and then they also count the votes. However, after counting the votes, the members of the election commission start having fun and driving the protocols from the polling stations to the regional representative offices.
Of course, each of the polling stations is connected by a road to its regional representative office. But itβs not that simple. As it happened, the roads are straight, and their lengths are multiples of a thousand meters.
Mr. Horodnyi, who is a member of the election commission, wondered how many kilometers the cars transporting the protocols will drive on this day. To find this out, he found a map with the polling stations and their corresponding regional representative offices marked on it.
Your task is to write a program that calculates how many kilometers the cars transporting the protocols will drive on election day.
Each polling station is assigned exactly one car, which can only travel to the corresponding regional representative office.
Input
The first line contains a single positive integer \(n\) β the number of polling stations.
The next \(n\) lines each contain 4 integers: \(x_1\), \(y_1\), \(x_2\), \(y_2\). The first two of them are the coordinates of the polling station. The next two are the coordinates of the corresponding regional representative office.
Output
In a single line, print a single non-negative integer β the number of kilometers that the cars transporting the protocols will drive on election day.
Constraints
\(1 \le n \le 10^5\),
\(0 \le |x_1|, |y_1|, |x_2|, |y_2| \le 1000\).
Samples
| Input (stdin) | Output (stdout) |
|---|---|
| 3 -3 2 1 5 0 0 6 8 4 7 6 7 | 17 |
Notes
The first car will drive 5 km. (From point (-3;2) to point (1;5)).
The second car will drive 10 km. (From point (0;0) to point (6;8)).
The third car will drive 2 km. (From point (4;7) to point (6;7)).
Total β 17 km.
Submit a solution
| Element Type | Created | Who | Problem | Compiler | Result | Time (sec.) | Memory (MiB) | # | Actions |
|---|
| Element Type | Created | Who | Problem | Compiler | Result | Time (sec.) | Memory (MiB) | # | Actions |
|---|