# | Problem | Pass Rate (passed user / total user) |
---|---|---|
13505 | String Calculator(class) 2 |
|
14278 | Bingo Battle |
|
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:
If b is an integer, a should be right-shifted b times, according to the following letter order: 0, 1, 2, ... , 9, a, b, ..., z. Otherwise the result is "error".- For example:
a = abcxyz, b = 3, result = def012 (that is, 'a'->'d', 'b'->'e', ..., and 'z'->'2'.)
- For example:
Input
The first line contains an integer N
The following N lines, each line contains two string a b and a operation op.
testcases:
(3/10) 1 <= N <= 100, 1 <= |a|, |b| <= 100, op = '+'
(3/10) 1 <= N <= 100, 1 <= |a|, |b| <= 100, op = '-'
(4/10) 1 <= N <= 100, 1 <= |a|, |b| <= 100, op = '@'
Output
The output contains N lines.
For each a b op, output the calculation result.
Sample Input Download
Sample Output Download
Partial Judge Code
13505.cppPartial Judge Header
13505.hTags
Discuss
Description
Doraemon and Capoo are playing a game of Bingo this time.
In this version of Bingo, Doraemon and Capoo each start with a blank NxN grid card. Before the game begins, they each write down NxN unique numbers ranging from 1 to 2xNxN on their cards, making sure the other player cannot see their numbers. The goal is to form a straight line of N marked numbers on the grid, which can be horizontal, vertical, or diagonal.
Here's how the game proceeds:
- Player A selects a number from their grid and announces it. Both players then mark this number on their grids if it's present. Then, it's Player B's turn to select and announce a number. Players take turns selecting and announcing numbers. Each time a number is called, both players check their grid and mark the number if they have it.
- The first player to get N numbers marked in a straight line (horizontally, vertically, or diagonally) on their grid wins the game (Bingo!). If both players manage to form a line of N marked numbers on the same turn, the game ends in a tie. If there are no more numbers to announce (end of the input) and neither player has achieved a bingo line, it is also declared a tie.
This is a partial judge problem. Write a program to determine the winner of their Bingo game. Please review the provided code and implement the section marked TODO in function.h.
Some hints: The desired number to mark is provided in the format of the number's position on the grid of the player that takes a turn, and it is passed to PlayerA/PlayerB::selectPosition()
. For the implementation of this class method, you have to call myOpponent->selectNumber()
and pass the number that was marked by ourselves, to let the opponent check whether the number is present on their board or not.
Example (N = 3)
Important: Please select C++17 to submit your solution.
Input
This problem consists of several test cases.
Each test case begins with a line containing an integer 5 ≤ N < 8, which indicates the game is played on an N×N grid. The test cases are formatted as follows.
<Player A's Name>
<Numbers on player A's N×N grid>
<Player B's Name>
<Numbers on player B's N×N grid>
<The position that Player A marks and announces>
<The position that Player B marks and announces>
<The position that Player A marks and announces>
<The position that Player B marks and announces>
...
The position that Player A or B marks and announces is formatted as two integers, x and y (0 ≤ x, y < N), which means to mark the number at the position of row x and column y (card[x][y]) on A or B's grid. It is guaranteed that the intended marked position has not been marked on that player's card yet. Please ignore those input positions of numbers that are going to be marked after a bingo line occurs and determine the winner of the round.
Output
The winner of the game will be outputted.