Amplitude Hackathon Summer '25 Problem 3 - Jenny the Beli Influencer

View as PDF

Submit solution

Points: 5 (partial)
Time limit: 2.0s
Memory limit: 1G

Problem type

Jenny has been using Beli to catalog her favorite places in San Francisco! For those who don't know, Beli can be used to rank restaurants. Beli asks the user to rate a restaurant first by whether they liked it, thought it was fine, or didn't like it, and then beyond that asks the user to stack-rank all restaurants within the initial three categories.

While browsing Beli, Jenny has stumbled upon a profile by someone named Jeni that has conveniently ranked exactly the same set of restaurants she has. Jenny is curious how similar their tastes are - specifically, the total number of restaurants that the two of them rated in the same category. Beli does not easily expose this functionality though, so it's your job to compute this!

Constraints

1 \le n \le 10^6

Subtask 1 [1 point]

n \le 50

Subtask 2 [1 point]

No additional constraints.

Input Specification

The first line will contain a single integer, n.

The next three lines summarize Jenny's Beli ratings. The three lines after that summarize Jeni's Beli ratings.

A summary of a given's user ratings uses exactly three lines. The first line describes the restaurants the user liked. The second line describes the restaurants the user thought was fine. The third line describes the restaurants the user didn't like. The description of restaurants within a single category always takes the form of an integer k, followed by k distinct integers from 1 to n, indicating in order from best-to-worst within the category, the restaurants as rated by the user.

Each restaurant is assigned a unique integer from 1 to n, and it is guaranteed that each integer appears in exactly one category for both users.

Output Specification

Output a single integer, the number of restaurants that both Jenny and Jeni rated in the same category.

Sample Input 1

4
1 1
2 4 2
1 3
2 1 2
2 3 4
0

Sample Output 1

2

Sample Explanation 1

The users both liked restaurant 1 and thought restaurant 4 was fine. Therefore, the answer is 2.


Comments

There are no comments at the moment.