## DMOPC '20 Contest 4 P3 - Roving Roombas

View as PDF

Points: 12 (partial)
Time limit: 2.0s
Memory limit: 256M

Authors:
Problem type

Tudor 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.

for all

for all

#### 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.

• commented on March 15, 2021, 5:36 a.m.

Notice how roombas move horizontally like rows and cords are vertical like columns. Coincidence? I think not!

• commented on Feb. 11, 2022, 5:18 p.m.

Uh... it is, lol.

• commented on March 15, 2021, 4:29 a.m. edit 2

#define int long long

• commented on April 16, 2021, 4:01 a.m.

That's so cringe.

• commented on April 16, 2021, 6:19 p.m.

no u

• commented on March 15, 2021, 6:03 a.m. edit 3