|
Time |
Memory |
Case 1 |
1 sec |
32 MB |
Case 2 |
1 sec |
32 MB |
Case 3 |
1 sec |
32 MB |
Case 4 |
1 sec |
32 MB |
Case 5 |
1 sec |
32 MB |
Case 6 |
1 sec |
32 MB |
Case 7 |
1 sec |
32 MB |
Case 8 |
1 sec |
32 MB |
Case 9 |
1 sec |
32 MB |
Description
There are interesting string operations there.
- 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 output "error".
- a [b]: Output the b-th character after sorting a in lexicographical order. If b exceeds the length of a, output "error".
- a @ b1_b2_b3_...bk: For all strings bi concatenated with '_', if a has appeared in string bi, add bi to a list, output the list in this order:
- If fx > fy: x is listed before y (fi is the number of occurrences of a in the string i )
- If |x| > |y|: x is listed before y
- If |x| = |y|: follows the lexicographical order
- a ? b1_b2_b3_...bk: You will receive the following T - 1 operations, output the result sorted according to the @ sorting rule in the end
- 1 i p q: represents bi = bp + bq
- 2 i p q: represents bi = bp - bq (If bq cannot be found in bp , ignore this operation.)
Input
The first line contains an integer T, representing the number of string operations.
The following T lines each contain a string Si , representing the string operation in the i-th round.
Subtasks
- Testcase 1: 1 ≤ T ≤ 1000, 1 ≤ |S | ≤ 104, only "+" operation, a and b are guaranteed to consist of lowercase letters
- Testcases 2 ~ 3: 1 ≤ T ≤ 1000, 1 ≤ |S | ≤ 104, only "-" operation, a and b are guaranteed to consist of lowercase letters
- Testcases 4 ~ 5: 1 ≤ T ≤ 1000, 1 ≤ |S | ≤ 105, only "[ ]" operation, a is guaranteed to consist of lowercase letters, and b is guaranteed to consist of digits
- Testcases 6: 1 ≤ T ≤ 1000, 1 ≤ |S | ≤ 104, only "@" operation, a and b are guaranteed to consist of lowercase letters and "_"
- Testcases 7: 1 ≤ T ≤ 1000, 1 ≤ |S | ≤ 105, only "@" operation, a and b are guaranteed to consist of lowercase letters and "_"
- Testcases 8: 1 ≤ T ≤ 10, 1 ≤ |S | ≤ 104, 1 ≤ i, p, q ≤ k, only "?" operation, a and b are guaranteed to consist of lowercase letters and "_"
- Testcases 9: 1 ≤ T ≤ 1000, 1 ≤ |S | ≤ 105, 1 ≤ i, p, q ≤ k, only "?" operation, a and b are guaranteed to consist of lowercase letters and "_"
Output
Output T lines, each containing a string Si after operation.
Please remember to print "\n" at the end.
Tags