DESCRIPTION OF THE PRIOR a set of integers (allowing duplicate elements), initially empty. We define as follows:
the Add x x added to collection
del set x to x equal to all the element deletion
ASK x in a case where the collection element x interrogation
of each operation, we require the following output.
set x add output operation after the number of
the number x set before the output operation del
ask first output indicating whether 0 or 1 was added to the set of x (0 indicates never added), and then outputs the number of the current set of x, intermediate opening by spaces. The first input line is an integer n, the number of commands. 0 <= n <= 100000.
N back line commands, as described in the Description. Total n output lines, each output line required.
Sample input
7
add 1
add 1
ask 1
ask 2
del 2
del 1
ask 1
Sample Output
1
2
1 2
0 0
0
2
1 0
#include <iostream>
#include <set>
using namespace std;
int main()
{
multiset<int>a;
set<int>v;
char s[5];
int n, p;
multiset<int>::iterator m;
cin >> n;
for (int i = 0; i < n; ++i) {
cin >> s >> p;
switch (s[1]) {
case 'd':
a.insert(p);
v.insert(p);
cout << a.count(p) << endl;
break;
case 'e':
cout << a.count(p) << endl;
m = a.find(p);
while (m != a.end()) {
a.erase(m);
m = a.find(p);
}
break;
case 's':
if (v.find(p) == v.end())cout << 0;
else cout << 1;
cout << ' ' << a.count(p) << endl;
break;
}
}
return 0;
}