# | Problem | Pass Rate (passed user / total user) |
---|---|---|
11422 | Shape |
|
13214 | Twenty One - Guard, Banker, Server and Players |
|
Description
Warning: You are not allowed to use malloc and free
Following the lecture slide :
Giving a bass-class Shape and 3 derived class : Triangle, Rectangle, Circle
You need to calculate the area and the perimeter of each shape.
note : You need to do some basic check: if the given information cannot form a shape (e.g. height of the rectangle is negative number....etc), then the area and perimeter would be both 0)
Input
There are only 3 shapes in this problem :
- Triangle, following by its 3 edges. (e.g. Triangle 3 4 5)
- Rectangle, following by its width and height. (e.g. Rectangle 5 7)
- Circle, following by its radius and the value of pi. (e.g. Circle 2 3.14)
Output
Ouput the total area and perimeter of all the shapes.
Sample Input Download
Sample Output Download
Partial Judge Code
11422.cppPartial Judge Header
11422.hTags
Discuss
Description
Kuo is curious about the casino after watching the movie, Twenty One.
There is a casino which opens N days this month.
Whenever someone enters the casino, they have to pay T entrance fee to the casino. The entrance fee may change every day.
There will be two kinds of events in a day.
- Guest <Someone> <Money> <Skill>. It means <Someone> enter the casino with <Money> money. <Someone> are their names, <Money> is the amount of money with them, and <Skill> is how well they play. If <Someone> are already in the casino or are blacklisted, ignore this event.
- Twenty One. It means there will be some players playing twenty one.
Everyone's name is composed of at most 4 English letters.
In a Twenty One game:
There will be one banker, one guard, and one server. They have banker_ski, guard_ski, and server_ski skill respectively.
There will be K players playing twenty one; however, ignore those who are blacklisted or not in the casino.
Each of the players places their bets beti first, then draw some cards.
The banker draws the cards last.
Let A be the sum of the i-th player's cards, B be the sum of the banker's.
Then:
- A > 21 and B > 21, nothing happens.
- A <= 21 and (B > 21 or A > B), the i-th player wins.
- B <= 21 and (A > 21 or B >= A), the i-th player loses.
For the banker:
- If the i-th player wins, the banker has to pay beti dollars to the i-th player.
- If the i-th player wins and skii < banker_ski, the banker has to pay the i-th player 10 * (the sum of the i-th player's cards) as a bonus.
- Furthermore, if the i-th player wins and the sum of the i-th player's cards is equal to 21, the banker has to pay 2*(bets + bonus) to the i-th player. (bonus may be equal to 0)
- For example, if the sum of the i-th player's cards is 21, skii < banker_ski, and beti = 1000, then the banker has to pay (1000+10*21)*2 to the i-th player.
- Whenever a player becomes bankrupt, the banker calls the guard to kick the player out and gives the guard 100 dollars.
- Whenever a player is seen to be a cheater; that is, 3*skii < the amount of money including the bets and the bonus the banker has to pay to the player, the banker calls the guard to kick the player out and gives the guard 100 dollars.
For the guard:
- When the guard has to kick i-th player who is a cheater out, if guard_ski < skii, the guard has to pay (skii - guard_ski) dollars to the i-th player; if guard_ski >= skii, the guard doesn't have to pay.
- When the guard has to kick a bankrupt player out, the guard doesn't have to pay.
For the player:
- If the i-th player loses, the i-th player has to pay beti dollars to the banker.
- If the i-th player loses but beti >= the amount of money the i-th player has now, the i-th player only has to pay all the money they have. In this case, the i-th player becomes bankrupt.
- If the i-th player is not in the casino or is already kicked out of the casino, ignore any of the i-th player's bets and cards.
- Whenever the i-th player wins this time and have more than server_ski dollars whether the player cheats or not, the i-th player will pay the banker 2000 dollars and the server 1000 dollars to buy some wine. (The player will have more than 3000 dollars when buying wine.)
The banker, the guard, and the server have 0 dollars at the beginning of each Twenty One game.
After each Twenty One game, the money the banker gets will be the casino's income.
If a player is kicked out of the casino by the guard, the player will be blacklisted.
If a person whose amount of money is less than or equal to T, this person will be charged nothing, kicked out, and blacklisted at once.
Those blacklisted are not permitted to enter the casino.
At the end of each day, everyone will leave the casino.
If the amount of income on this day is bigger or equal to a number U, the boss of the casino, JN will feel happy and clear the blacklist.
You can use this code to draw cards.
void Human::Draw() {
this->cards = 0;
string res = "";
while (res.size() <= 0)
getline(cin, res);
stringstream ss(res);
while (ss >> res) {
int temp = 0;
for (auto i : res)
temp = temp * 10 + i - '0';
this->cards += temp;
}
}
Input
The first line of the input contains a number N — the number of days in this month.
The following contains N blocks.
The first line of each block is Casino Q T U — it means there will be Q events, the entrance fee is T and the U mentioned in the description this day.
The next Q lines are one of the following:
- Guest <Someone> <Money> <Skill>
- Twenty One
For a Twenty One event:
The first line of the block contains three numbers — banker_ski, guard_ski, and server_ski.
The second line of the block contains a number K — the number of players.
For the next 2K lines, i = 1, 2, ..., K,
There will be a string namei and a number beti in the 2i - 1 line — the i-th player's name and the bets they place.
There will be some numbers c1, ..., ct in the 2i line — the cards the i-th player has.
The last line of each block will be some numbers c1, ..., ct — the cards the banker has.
N, Q <= 100
K <= 200
server_ski >= 10^4
- testcase 1 to 6:T = 0, U = 109, server_ski = 109, all number is within the range of int.
- testcase 6 to 9:U = 109, server_ski = 109, all number is within the range of int.
- testcase 11 to 12:server_ski = 109, all number is within the range of int.
- testcase 13 to 15:All number is within the range of int.
Output
For every Twenty One game:
The first line of output should contain three numbers banker_money, guard_money, and server_money — the money the guard, the banker, and the server gets.
Each of the next N lines should contain a string namei and moneyi — the name of the player and the money they have after playing, in the order of the time they enter the casino.
You should print a number U at last — how much income the casino gets in this month.
If there are K people blacklisted, you should output their names in K lines in the order they get blacklisted.