1435 - DS_18_CHEN_quiz2 (CS2351) Scoreboard

Time

2018/04/16 18:35:00 2018/04/16 20:35:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
11890 Santa List

11890 - Santa List   

Description

Objective

   ⁍ Find out the Santa list of Christmas gifts

   ⁍ Each node stores a child name and the gift

   ⁍ Naughty kids can only get a lump of coal

   ⁍ Examples:

(Andy,paper)->(Sandy,Candy)->(David,coal)


Requirements

   ⁍ SantaList will be initialized with the input at the first line

   ⁍ AppendList: The gift list can be appended (good kids should be placed before naughty kids)

◦ Assuming no child's name repeat.

◦ Only naughty kids will get "coal". (In other words, "coal" will not appear in SantaList and AppendList)

 

   ⁍ NaughtyKid: He will check the naughty list and get names one by one

◦ Each naughty kid’s gift will be replaced with coal and move to the end of the list.

◦ Naughty kids can be named many times, and each time they are moved to the end of the list.

◦ The name of the naughty kid must already exist in the list (may be good or naughty).
   

   ⁍ You should find out the final Santa List

 
 

Input

   ⁍  The last line of input is "End", and we only need to print the result when get the "End".

 

Input format:

<command>  <n>  < data (or data pair) repeat n times>

 n is an integer and ≥ 0 

Output

 

Print

   ⁍​ First line: Empty or SantaFinalList​

   ⁍​ Second line: List of children and their corresponding gifts (or coal)

◦  If it's Empty, only need to print the first line.

◦  Connect with symbols "->"

◦  No space in between

 

Output format:

Sample Input  Download

Sample Output  Download

Tags




Discuss