All submissions for this problem are available.
Welcome to Beurre Blanc the most trendy restaurant in town! Where there is a special everyday! What’s so special about these special dishes you ask? Each special is made under the supervision of a “Head Chef” and his selected team of assistant chefs from the team of chefs employed at the restaurant.
To encourage and highlight each chef’s unique style and dishes, each chef on the team is given one day to make his/her special dish. All chefs who are assistants to the head chef will be required to help the chef prepare his/her special. Further, any chef who is an assistant to any of the chefs involved in making the special will also have to help in making the dish.
If there are N chefs employed at the restaurant, each chef will get to make his special every N days. That is, chef 1 makes his dish on day 1, chef 2 on day 2… and chef N on day N.
Given the number of chefs, N, and the assistant chefs of every chef who has assistants under him/her, How many chefs are involved on each day of the N-day cycle?
- The first line contains the number of chefs, N.
This is followed by 2 lines for each chef who has assistants under him/her.
The first line contains the Chef Number of the Head chef and the second line contains the number of assistants under him/her, M, followed by M chef numbers who serve as the assistants of the Head Chef.
N lines containing a single integer representing the number of chefs involved on each day of the N day cycle.
- 1 < N < 100
- 0 <= M < N
Input: 3 1 2 2 3 2 1 1 Output: 3 3 1
The first line says that there are 3 chefs (N=3)
The next pair of lines describe the assistants of chef 1. The first line within the first pair describes the head chef number (1) and the next line describes that he has 2 assistants given by the chef numbers 2 and 3.
The next pair of lines describe the assistants of chef 2. The first line within the second pair describes the head chef number (2) and the next line describes that he has 1 assistant given by the chef number 1.
The output contains 3 integers (one for each chef) ,each in their own line, which describes the number of chefs involved in the day a chef makes his special (line number is indicative of the relevant headchef number).
The first line represents the number of chefs cooking on day 1 (when chef 1 makes his special) and contains "3". It would be chef 1 and his two assistants chef 2 and chef 3.
The second line represents the number of chefs cooking on day 2 (when chef 2 makes his special) also contains "3". It would be chef 2 and his assistant chef 1 and the assistants of chef 1 (chef 1 and 2). (Chef 2 is counted only once)
The third line represents the number of chefs cooking on day 3 (when chef 3 makes his special) and contains "1". It would be only chef 3 as he has no assistants
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.5, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, CLOJ, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.