Amplitude Hackathon Summer '25 Problem 4 - Regina the Social Media Manager
View as PDFRegina is in charge of the latest social media campaign to advertise Amplitude!
There are users that Regina could target as part of the campaign. Specifically, each user has
a type of device and also a preferred social media application. As part of the campaign, Regina
will target all users that either use a given type of device or a given social media application.
Regina has come up with plans for how to run the campaign, each one specifying a specific
type of device as well as a specific social media application. For each planned campaign, compute
the number of users that would be targeted.
Constraints
Subtask 1 [1 point]
Subtask 2 [1 point]
No additional constraints.
Input Specification
The first line contains a single integer, .
The next lines contain two integers,
and
, indicating that the
user has device
type
and uses social media application
.
The next line contains a single integer, .
The next lines contain two integers,
and
, indicating that the
plan is to target
all users that either have device type
or use social media application
.
Output Specification
For each query, output a single integer, the number of users targeted.
Sample Input 1
4
1 1
1 1
1 2
3 1
3
1 1
4 2
4 3
Sample Output 1
4
1
0
Sample Explanation
For the first query, we want to count how many users have device type or use social media
application
. The first three users have device type
and both the first and last user use social media
application
, so the answer is
.
For the second query, we want to count how many users have device type or use social media
application
. No one uses device type
, and the third user uses social media
application
, so the answer is
.
For the third query, we want to count how many users have device type or use social media
application
. No such users do, so the answer is
.
Comments