# | Problem | Pass Rate (passed user / total user) |
---|---|---|
13485 | String Calculator(class) |
|
13862 | Pineapple senpai’s family |
|
14600 | Caillou's Tetris game |
|
Description
In this problem, you need to finish a string calculator.
The calculator has three string operators:
- a + b: Concatenate the string b after the string a.
- a - b: If string b has appeared in string a, delete the first appearance of b in a, otherwise the result is "error".
- a / b: The number of occurrences of string b in string a.
Note: You are suggested to practice the usage of C++ string class (https://www.cplusplus.com/reference/string/string/).
- function std::operator+: Concatenate strings (https://www.cplusplus.com/reference/string/string/operator+/)
- public member function std::string::find: Find content in string (https://www.cplusplus.com/reference/string/string/find/)
- public member function std::string::substr: Generate substring (https://www.cplusplus.com/reference/string/string/substr/)
- etc.
Input
The first line contains an integer N
The following N lines, each line contains two string a b.
testcases:
(6/6) 1 <= N <= 100, 1 <= |a|, |b| <= 100
Output
The output contains N lines.
For each a b, output ((a - b)+b)/b
Sample Input Download
Sample Output Download
Partial Judge Code
13485.cppPartial Judge Header
13485.hTags
Discuss
Description
Pineapple Senpai is introducing his family to you.
Each member of his family has some strong relatives such as ParentA, ParentB, Mate, and Child.
And there would be a narrator in the family, who is responsible to introduce the family to you.
Initially, the narrator is Pineapple Senpai himself, and the narrator would introduce his relative's attributes such as gender, age, name, and personality.
Each relative is selected by a strong-relative-chain. For example, if the strong-relative-chain is "ParentA Child", it means that the relative is the narrator's ParentA's Child(which is the narrator itself).
So there are three types of queries you need to proceed
- 1 strong-relative-chain this type of query asks you to change the narrator to the current narrator's relative, which is selected by the strong-relative-chain.
- 2 strong-relative-chain attribute-modification this type of query asks you to change the attribute of the current narrator's relative, which is selected by the strong-relative-chain. the attribute-modification's would specify the name of the attribute, and the value to be changed. There are four types of attributes: "Gender: ENUM, Age: INT, Name: STRING, Personality: STRING".
- 3 this type of query asks you to print the info of the current narrator, you should call the built-in function directly.
Note that the first time every relative is introduced to you, there may be some information that is not directly revealed by the narrator but you should notice.
When a Child is first introduced to you, at least one of its parent is introduced early, which should be the Child's ParentA.
A Child's ParentA and ParentB should always be Mate to each other.
If B is A's Mate, A's Child would be B's Child, too.
Each time a perstonality is described, you should concatenate the new described personality behind the original personalities spacing by a single space character.
- \(1 \leq Q \leq 1000\)
- \(1 \leq len(strong-relative-chain) \leq 1000\)
- \(1 \leq len(attribute-chain) \leq 200\)
Constraints
This is a Partial judge Problem.
All you need to do is to implement the getRelative and describe function.
For the getRelative function, you should return the pointer to the relative that is selected by the strong-relative-chain
For the describe function, you should modify the corresponding attribute of the relative selected by the strong-relative-chain
Note that you should compile the solution with C++17.
Input
Output
Sample Input Download
Sample Output Download
Partial Judge Code
13862.cppPartial Judge Header
13862.hTags
Discuss
Description
CSSA's most handsome president Chang Cailou recently felt that riding motorcycles outdoors was too boring, so he developed a special Tetris game and would like you to help him test this game.
The special Tetris game screen has N rows and M columns. Every second, a block will fall until it reaches the bottom or rests on another stationary block.
When all cells in a row are filled with stationary blocks, that row will be eliminated, and all blocks above will move down one row.
The game lasts for T seconds, during which K blocks will be placed. Each block will be placed into the game at a designated time point P, in a 3×3 grid with top-left corner at coordinates (X, Y) . Any block's position and shape are guaranteed not to exceed the game boundaries and will only be placed in positions where no blocks have appeared before.
Finally, output the game screen at the time the game ends.
'*'
represents blocks that will continue to move'#'
represents stationary blocks that have stopped'.'
represents position where no block has appeared yet
For sample input 2:
At time 2, 4, and 5, blocks will be added to the game screen.
At time 8, a block is added at position (5, 7). At this moment, the first block that was added reaches the bottom and becomes stationary. It is represented by '#'
instead of '*'
.
When the time reaches 9, all blocks become stationary blocks. At this moment, the bottom row is entirely made up of stationary blocks, so an elimination is performed.
This problem is a partial judge.
Please implement functions defined in the header file.
- update: Update the game state to reflect the situation at P-th second.
- addBlock: Add a block to the scene at position (X, Y) .
- checkRow: Check whether the row needs to be eliminated.
- eliminate: Eliminate the row.
- print: Print the game screen.
Input
The first line contains three integers N, M, T, indicating the Tetris game size is N * M and the game lasts for T seconds.
The second line contains an integer K, indicating K blocks will be placed during the game.
The next K groups contain block information:
-
The first line of each group contains three integers Pi , Xi , Yi , indicating the i-th block will be placed at Pi seconds into the game, in a 3×3 grid with top-left corner at coordinates (Xi , Yi ) . Each placed block is guaranteed not to split.
Pi is guaranteed to appear in ascending order, and all blocks are guaranteed to have enough space for placement. -
Following this is a 3×3 grid using
'*'
to represent cells with blocks and'.'
to represent empty cells, showing the block's shape.
Constraints
- 1 ≤ N, M ≤ 100
- 1 ≤ T, P ≤ 15000
- 1 ≤ K ≤ T
- 1 ≤ X ≤ N
- 1 ≤ Y ≤ M
Subtasks
- Testcases 1 ~ 3: K = 1
- Testcases 4 ~ 6: No elimination operation
- Testcases 7 ~ 9: No additional restrictions
Output
Output the game screen at the time the game ends.
'*'
represents blocks that will continue to move'#'
represents stationary blocks that have stopped'.'
represents position where no block has appeared yet
Please remember to print "\n" at the end.