Problem T
Enn Eitt EEEE Erfiði
Languages
en
is

Arnar is going mad from all these abbreviations and
shorthands at his job. Everything from DDI, i13n, o11y to
LASIK. He can’t read half a page without having to stop to look
up all kinds of acronyms. Eventually he decides to do something
about this and is going to collect some info on the complexity
of his reading material to show how bad the problem has gotten.
He is of course busy doing his job, so he gets you to calculate
the complexity of all the acronyms in his data set. The
complexity of an acronym is the number of acronyms you need to
define to understand the meaning of the initial acronym. For
example, the complexity of LASER (Light Amplified by Stimulated
Emission of Radiation) has a complexity of
Input
The first line of input contains an integer
Output
For each acronym that appears in the input, print its complexity on its own line, in the same order as the acronyms are defined in the input.
Scoring
Group |
Points |
Constraints |
1 |
10 |
Acronyms do not refer to other acronyms, |
2 |
15 |
All acronyms are defined before being referred to and
no two different acronyms refer to the same acronym,
|
3 |
10 |
All acronyms are defined before being referred to and no two different acronyms refer to the same acronym. |
4 |
40 |
|
5 |
25 |
No further constraints. |
Explanation of samples
In the first sample LASER, IP, DNS and DHCP do not refer to
any other acronyms, so they only need to define themselves.
Thus their complexities are all
In the second sample YARA, DB and UNIX all have complexity
Sample Input 1 | Sample Output 1 |
---|---|
7 LASER 7 light amplified by stimulated emission of radiation LASIK 5 LASER assisted in situ keratomileusis IP 2 internet protocol IPAM 3 IP address management DNS 3 domain name system DHCP 4 dynamic host configuration protocol DDI 3 DNS DHCP IPAM |
1 2 1 2 1 1 5 |
Sample Input 2 | Sample Output 2 |
---|---|
9 PHP 3 PHP hypertext preprocessor DB 2 data base XAMPP 6 XAMPP apache maria DB PHP perl HURD 5 HIRD of UNIX replacing daemons UNIX 5 uniplexed information and computing service HIRD 5 HURD of interfaces representing depth GNU 3 GNU not UNIX GNULINUX 5 GNU not UNIX linus UNIX YARA 4 yet another recursive acronym |
1 1 3 3 1 3 2 3 1 |