Pagini recente » Cod sursa (job #2083900) | Cod sursa (job #3260405) | Cod sursa (job #1957461) | Cod sursa (job #2210748) | Cod sursa (job #2143267)
#include <iostream>
#include <fstream>
#include <vector>
#define in vector<int>::iterator
using namespace std;
ifstream f("hashuri.in");
ofstream g("hashuri.out");
const int M = 666013;
vector<int> H[M];
int n;
inline in Find(int x)
{
int l = x % M;
for(in it = H[l].begin(); it != H[l].end(); ++it)
if(*it == x)
return it;
return H[l].end();
}
inline void Insert(int x)
{
int l = x % M;
if(Find(x) == H[l].end())
H[l].push_back(x);
}
inline void Delete(int x)
{
int l = x % M;
in it = Find(x);
if(it != H[l].end())
H[l].erase(it);
}
int main()
{
int k, val;
f >> n;
for(int i = 1; i <= n; ++i)
{
f >> k >> val;
if(k == 1) Insert(val);
else if(k == 2) Delete(val);
else g << (Find(val) != H[val%M].end()) << "\n";
}
}