Dept. of Computer Science and Engineering, Czech Technical University in Prague
Faculty of Mathematics and Physics, Charles University in Prague
Faculty of Electrical Engineering and Computer Science, Technical University of Ostrava
Faculty of Informatics and Information Technologies, Slovak University of Technology
Faculty of Informatics, Masaryk University
Faculty of Management Science and Informatics, University of Zilina
CTU Open Contest 2008
banking.c, banking.C, banking.java, banking.p
A central bank is an institution that is responsible for the monetary policy of a country. Beside
others, it monitors and supervises other banks. Your task is to write a computer program that
will serve as a simple supervision instrument for monitoring bank accounts.
The input contains several scenarios. Each scenario begins with a line containing a single positive
integer A, the number of bank accounts at the beginning of the supervision, 0 < A <= 100. Then
there are A lines each describing one account. Such a line contains the account number, one
space, and a non-negative decimal number specifying the account balance.
Each of the following lines specifies a request for one bank operation. The line begins with
a command and then, separated by a space, there are optional parameters. The list of commands
follows, the third column in the table shows the number of parameters.
Create a new account
New account numb er
Deposit cash to some account
Account number, Amount to deposit
Withdraw cash from an account
Account number, Amount to withdraw
Wire transfer of money
Source account, Target account, Amount
The number of requests in every scenario will always be between 0 and 1000 (inclusive). The
last request of a scenario is followed by the word "end" and one empty line. Then the next
scenario begins. The last scenario is followed by a line containing zero in place of A.
All account numbers consist of exactly four decimal digits followed by a slash character ("/")
and one digit specifying a code of the bank that operates the account. Each bank has its own
Amounts are always given as non-negative decimal numbers with exactly two digits after the
decimal point. No amount in the input will be higher than 10 000. No unnecessary leading zeros
are permitted, i.e., only amounts strictly less than 1.00 may start with a zero.
For each request, output exactly one line. The line must begin with the command followed
by the amount parameter (if present) separated from the command by a space. Then there is
a colon (":"), one space and the result of the operation.
create: If there is already an account with the same number in the same bank, the result will be
"already exists". Otherwise, create the account (with the initial balance of zero) and output
For all commands other than create, if there is no account with the number specified as a pa-
rameter, the result will always be "no such account". If the account exists (or both accounts
do), the following rules apply.