Time limit: 3 seconds Memory limit: 256 MB In order not to waste his time in the summer,…
- User
Time limit: 3 seconds Memory limit: 256 MB In order not to waste his time in the summer, Hosni turned to business and recently established a bank called Konab. Since he wants you to be a member of Kanab, he gave you a project and asked you to write a bank account that implements the following requests.
1 ip:username Plain text This request means that a user with the username username and IP address was connected to Mobile Bank, and if the username is not valid, you should print invalid username. We call a valid username if it consists of only uppercase and lowercase English letters and numbers. For example, 1aAB2 is valid, but ab*2 is not valid.
2 ip:username:money Plain text This request means that the user with the IP address ip has transferred money to the account with the user name username. In fact, you should subtract money from the ip account and add it to the username account.
3 ip Plain text By giving this request, show the amount of money in the person's account with the IP address.
(Note that each person's money can be negative and everyone has 0 units of money at the beginning)
entrance In the first line of input number q q, which represents the number of requests, will be given to you, and in q q The next line, one request is given in each line.
In each request, the type is first given, which is equal to one of the numbers 1, 2, or 3, and if t y p e type is equal to 1, then you will be given two strings, ip and username, which are separated by the : character. If t y p e type is equal to 2, three strings ip, username and money are given, which are separated by: and if t y p e If type is equal to 3, the ip string is given.
0 ≤ q , m O n e y ≤ 100
000 0≤q,money≤100,000
The maximum length of username and ip is 15.
It is guaranteed that:
A user cannot connect to the bank twice, and no two people's IP and username are the same. If the username is not valid, only _ or * or # or $ characters may be used in it. All type 2 and 3 inputs are valid; It means that there is a user with the specified IP or username. All IPs are 4 numbers between 0 and 255 separated by periods. The maximum amount of money a person can have 1 0 9 10 9 is output For each type 1 request, if the username is not valid, you must print invalid username, and for each type 3 request, you must print the amount of money in the requested person's account. (Print the answer to each prompt on a new line.)
Example Sample input 9 1 46.51.16.72: SmsS 1 192.168.10.13:#hacker$user 1 131.41.61.213:faeila 2 46.51.16.72:faeila:1000 3 46.51.16.72 3 131.41.61.213 2 131.41.61.213:SmsS:500 3 46.51.16.72 3 131.41.61.213 Plain text Sample output Invalid username -1000 1000 -500 500 write code code in java
- Assistant