Standard Template Library


Plus
Pin


Problem description Progress
ID 30684. Sets in C++
Темы: Standard Template Library    Sets   

Input
Given a number N (1 <= N <= 100000) – number of requests. The following N lines contain the character ‘+’ or ‘-’ and the number a (1 <= a <= 1000000000). If the symbol – ‘+’, then the number a is added to the set, otherwise – removes all a values ​​that were previously added.
It is guaranteed that when a number is removed, it is contained in the set.

Imprint
It is required to display in ascending order all unique elements in the set after all queries are completed, or "-1" if there are no elements in the set.

 

Examples
# Input Output
1
3
+1
+2
-1
2
2
3
+1
+1
-1
-1
3
3
+1
+1
+1
1

ID 29643. Array queries
Темы: Standard Template Library   

You need to implement an array-based data structure that can respond to these types of requests:

0 - print array size and newline sign;
1 x - add the number x to the end of the array;
2 - remove the last element of the array;
3 x y - insert number y between array elements x and x + 1;
4 x - remove element №x;
5 - display all elements of the array in the order they appear in it, separated by a space. At the end, output a newline sign;
6 x - change array size to x. If x is less than the current size of the array, then all elements starting from element №x are discarded. If x is greater than the current size of the array, then the resulting array elements will be equal to 0.
 
Input: 
- the first line contains the number N (\(1 <= n <= 100\));
- the next N lines contain requests in the format written in the condition.
 
Output: Print responses to queries like 0 and 5.
 
Examples
# Input Output
1
9
0
1 5
2
0
10
1 3
2
1 1
5
0
0
0 1