Pagini recente » Cod sursa (job #3259418) | Cod sursa (job #873298) | Cod sursa (job #2067237) | Cod sursa (job #890460) | Cod sursa (job #529062)
Cod sursa(job #529062)
// infoarena: problema/hashuri //
#include <fstream>
#include <set>
using namespace std;
ifstream in("hashuri.in");
ofstream out("hashuri.out");
const int MAXN = 1000010;
const int HASH_PRIME = 666013;
template<typename T>
struct hash
{
multiset<T> h[HASH_PRIME];
void push(T val)
{
h[val%HASH_PRIME].insert(val);
}
void pop(T val)
{
typeof(h[0].end()) it = h[val%HASH_PRIME].find(val);
if(it == h[val%HASH_PRIME].end())
return;
h[val%HASH_PRIME].erase(it);
}
bool find(T val)
{
return h[val%HASH_PRIME].find(val) != h[val%HASH_PRIME].end();
}
};
hash<int> h;
int n,a,b,i;
int main()
{
in>>n;
for(i=1; i<=n; i++)
{
in>>a>>b;
if(a == 1)
h.push(b);
else if(a == 2)
h.pop(b);
else
out<<h.find(b)<<'\n';
}
return 0;
}