# | Problem | Pass Rate (passed user / total user) |
---|---|---|
13485 | String Calculator(class) |
|
14606 | Caillou's Tetris game II |
|
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
CSSA's most handsome president Chang Cailou is also a perfectionist. He has developed a new game mode for his special Tetris game, and hopes you can help him test this new mode.
In the new mode, the special Tetris game screen has 8 rows and 9 columns. Every second, a block will fall until it reaches the bottom or rests on another stationary block.
Initially, there will be some stationary blocks. Then a block will be placed, consisting of a 3x3 grid, with (X, Y) being the coordinates of the top-left corner. It is guaranteed that there is enough empty space for the block to be placed.
After placement, K operations will be performed.
- L: moving left
- R: moving right
- D: continuing downward without any horizontal movement
If a movement would cause collision with a stationary block or go beyond the game screen, the move is illegal and should be ignored. The block will not become stationary.
Finally, output the game screen after K operations.
'*'
represents the placed block'#'
represents stationary blocks that have stopped'.'
represents position where no block has appeared yet
For sample input (RLRR):
This problem is a partial judge.
Please implement functions defined in the header file.
- update: Update the game state after each operation.
- moveBlock: Executes horizontal movement operations.
Input
Initially, there is an 8x9 two-dimensional array representing the initial game screen.
The next line contains two integers X, Y, indicating the coordinates (X, Y) of the top-left corner of the 3x3 grid where a block will be placed.
Following this is a 3×3 grid using '*'
to represent cells with blocks and '.'
to represent empty cells, showing the block's shape. Each placed block is guaranteed not to split.
The last line contains an integer K, representing the number of operations.
The next K lines each contain one operation:
- L: moving left
- R: moving right
- D: continuing downward without any horizontal movement
Constraints
- 1 ≤ K, X ≤ 8
- 1 ≤ Y ≤ 9
Subtasks
- Testcases 1 ~ 2: Only D operation
- Testcases 3 ~ 4: No need to ignore any operations
- Testcases 5 ~ 6: No additional restrictions
Output
Output the game screen after K operations:
- L: moving left
- R: moving right
- D: continuing downward without any horizontal movement