# | Problem | Pass Rate (passed user / total user) |
---|---|---|
13505 | String Calculator(class) 2 |
|
13889 | Pineapple Senpai's Big Family |
|
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
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 for introducing 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 four 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.
- 4 You have to print the number of pairs of mates via the getAns() function. (Because Pineapple Senpai is such a winner, he wonders how many people are not winners in his family.)
Note that at 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've noticed.
When a Child is first introduced to you, at least one of its parent is introduced earlier, 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, describe and getAnsfunction.
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
For the getAns function, you find a way to maintain the number of pairs of mates yourself.