Woburn Challenge 2018-19 Round 2 - Junior Division
Problem 3: Seeing Double
While on an undercover mission in Montreal, agents Ethan Hunt and Benji Dunn of the IMF (Impossible Mission Force) will need to attend an exclusive party to listen in on a terrorist scheme. Of course, they'll both need to disguise themselves as members of the party's guest list to gain entry.
Ethan has a set of N (1 ≤ N ≤ 100) masks, the i-th of which allows him to impersonate a person whose name is a string Ai. Benji agent similarly has M (1 ≤ M ≤ 100) masks, the i-th of which allows him to impersonate a person whose name is a string Bi. Each of the N + M names is a non-empty string consisting of at most 20 lowercase letters "
z". Neither agent has any duplicate masks in their own set — in other words, the names A1..N are distinct from one another, and the names B1..M are also distinct from one another.
Ethan and Benji will each select one of their masks and wear it to the party. However, they'll run into trouble if they happen to both impersonate the same person! Help them determine how many different people exist who might be impersonated by both agents simultaneously.
The first line of input consists of a single integer, N.
N lines follow, the i-th of which consists of a single string, Ai, for i = 1..N.
The next line consists of a single integer, M.
M lines follow, the i-th of which consists of a single string, Bi, for i = 1..M.
Output a single integer, the number of different people who might be impersonated by both agents simultaneously.
3 kurt john solomon 4 franz solomon kurt james
It's possible for both Ethan and Benji to impersonate "
kurt". It's also possible for both of them to impersonate "
solomon". There are no other people who might be impersonated by both agents.
Point Value: 5 (partial)
Time Limit: 2.00s
Memory Limit: 16M
Added: Dec 14, 2018
C++03, PAS, C, HASK, ASM, RUBY, PYTH2, JAVA, PHP, SCM, CAML, PERL, C#, C++11, PYTH3