Programming Problem #3:set
Source: POJ (Coursera statement: The exercises completed on POJ will not count against the final results of Coursera. )
Note: Total time limit: 5000ms memory limit: 100000kB
Describe
An entire set of existing integers (with duplicate elements allowed), initially empty. We define the following actions:
Add x to add X to the collection
Del x removes all elements in the collection that are equal to X
Ask x query for the case of element x in the collection
For each of these operations, we require the following output.
The number of x in the collection after the Add output operation
The number of x in the collection before the DEL output operation
Ask first outputs 0 or 1 to indicate if X has ever been added to the collection (0 means it has not been added), and then outputs the number of x in the current set, with an empty opening in the middle.
Input
The first line is an integer n, which represents the number of commands. 0<=n<=100000.
The following n-line command, as described in description.
Output
A total of n rows, each line output as required.
Sample input
7add 1add 1ask 1ask 2del 2del 1ask 1
Sample output
121 20 0021 0
Tips
Please use STL's set and multiset to finish the task
POJ C + + program programming problem # # # Set Programming Job-STL2