#C12446. Automated Bank Transaction Processing

    ID: 41874 Type: Default 1000ms 256MiB

Automated Bank Transaction Processing

Automated Bank Transaction Processing

This problem simulates an automated bank that processes transactions. Each transaction has a unique ID, a user ID, a transaction type (deposit or withdrawal), and an amount. The program should compute the final balance for each user, record all valid transactions (sorted by transaction ID), and log errors when a withdrawal exceeds the available balance. In such cases, the withdrawal is skipped and an error message is generated in \(\LaTeX\) format if needed.

For example, if user1 deposits 100 and then withdraws 50, the balance is 50. A subsequent withdrawal of 60 for user1 would be skipped and an error logged.

inputFormat

The first line contains an integer T, the number of transactions. Each of the next T lines contains four space-separated values: transaction_id (integer), user_id (string), transaction_type (string: either 'deposit' or 'withdrawal'), and amount (integer). Input is read from stdin.

outputFormat

Output three lines to stdout. The first line is a Python-style dictionary of user balances (with keys in single quotes). The second line is a list of processed transactions sorted by transaction_id, where each transaction is represented as a tuple in the form: (transaction_id, 'user_id', 'transaction_type', amount). The third line is a list of error messages. If there are no errors, output an empty list [].## sample

1
1 user1 deposit 100
{'user1': 100}

[(1, 'user1', 'deposit', 100)] []

</p>