New times P69424


Statement
 

pdf   zip

html

Remember the old days when Informatics was a boring discipline, when bloody algorithms and maths were considered important, and when the fundamentals of computer science were thought in faculties? (What an heresy …) Fortunately, those days are over, my friend!

What is very important today is to be prepared for entering into the fascinating world of consulting: Keeping the balance of thousands of accounts updated, producing beautifully formatted outputs, wearing neckties the whole day, …Yes, that’s the way!

Are you prepared for the new times? Let’s check it! In this problem you will have to keep the balance of several accounts, and produce nicely written output reports. (It is up to you to wear a necktie or not.)

Input

Input begins with the number of cases. Every case has five kinds of operations:

  • To create a new account with 0 money: NEW <account name>
    Prints an error message if the account already exists.
  • To transfer money: TRANSFER <account name 1> <account name 2> <quantity>
    Prints an error message for each non-existing account.
  • To print the current money of an account: QUERY <account name>
    Prints an error message if the account does not exist.
  • To remove an account: DELETE <account name>
    Prints an error message if the account does not exist.
  • To end a case: END

The names of the accounts are made up only of lower-case letters and digits. The given quantities and the current money of every account will always fit into a C++ integer variable.

Output

Begin the output for each case with a line with its number starting at 1. Afterwards, print a line for every correct query and every error message, in the same order in which they happen. To make the problem even more interesting (if possible), every line of the same case must have the same length, which should be chosen as short as possible. If needed, add asterisks to the left of error messages, and spaces to the left of the current money of the accounts. Finish every case with a line with the appropriate number of dashes. Every given case will have at least one line of output.

Public test cases
  • Input

    4
    
    QUERY corleone
    NEW corleone
    QUERY corleone
    NEW corleone
    NEW fanucci
    TRANSFER corleone fanucci 100
    QUERY corleone
    QUERY fanucci
    END
    
    QUERY leia
    DELETE chewbacca
    TRANSFER r2d2 c3po 1000
    END
    
    NEW c3po
    TRANSFER r2d2 c3po 4000000
    NEW r2d2
    TRANSFER r2d2 c3po 4000000
    NEW chewbacca
    QUERY c3po
    QUERY leia
    TRANSFER r2d2 chewbacca 60000000
    QUERY r2d2
    TRANSFER r2d2 leia 1000
    NEW r2d2
    QUERY r2d2
    DELETE r2d2
    QUERY r2d2
    END
    
    NEW r2d2
    QUERY r2d2
    END
    

    Output

    Case #1
    *****Account corleone not found.
    Money of corleone:            0.
    Account corleone already exists.
    Money of corleone:         -100.
    Money of fanucci:           100.
    --------------------------------
    Case #2
    *****Account leia not found.
    Account chewbacca not found.
    *****Account r2d2 not found.
    *****Account c3po not found.
    ----------------------------
    Case #3
    *****Account r2d2 not found.
    Money of c3po:      4000000.
    *****Account leia not found.
    Money of r2d2:    -64000000.
    *****Account leia not found.
    Account r2d2 already exists.
    Money of r2d2:    -64000000.
    *****Account r2d2 not found.
    ----------------------------
    Case #4
    Money of r2d2: 0.
    -----------------
    
  • Information
    Author
    Salvador Roura
    Language
    English
    Official solutions
    C++
    User solutions
    C++