DMOPC '20 Contest 4 P3 - Roving Roombas
View as PDFTudor is managing his Roombas!
Tudor has a total of  Roombas which he uses to clean his room. His Roombas each clean parts of a row in his square room, specifically, going from 
 to 
.
Unfortunately, Tudor also has  server cords, each taking up parts of a column in his room, specifically, going from 
 to 
.
Tudor is going to let his Roombas clean his room, and he wonders: how many times will any Roomba run over a cord? Note that if a Roomba runs over the end of a cord, it still counts.
Constraints
 for all 
 for all 
Subtask 1 [5%]
Subtask 2 [10%]
Subtask 3 [15%]
Subtask 4 [70%]
No additional constraints.
Input Specification
The first line contains  integers 
 and 
.
The next  lines each contain 
 space-separated integers 
 and 
, representing the path of a Roomba.
The next  lines each contain 
 space-separated integers 
 and 
, representing a cord.
Output Specification
On one line, output the number of times any Roomba will run over a cord.
Sample Input
3 3
7 2
7 5
5 7
3 1
7 5
4 5
Sample Output
4
Explanation
The Roombas are shown going left to right, and the cords from the bottom up. There are four points of intersection.
Comments
Notice how roombas move horizontally like rows and cords are vertical like columns. Coincidence? I think not!
Uh... it is, lol.
#define int long longThat's so cringe.
no u
inspire my grad quote