Pagini recente » Cod sursa (job #345603) | Cod sursa (job #1088787) | Cod sursa (job #2531288) | Cod sursa (job #1141378) | Cod sursa (job #2195410)
#include <fstream>
#include <algorithm>
using namespace std;
ifstream cin ("hashuri.in");
ofstream cout ("hashuri.out");
#define MOD 999983
int n;
vector< vector<int> > a;
void Add(int x)
{
int h = x % MOD;
a[h].push_back(x);
}
void Delete(int x)
{
int h = x % MOD;
for (unsigned int i = 0; i < a[h].size(); i ++)
if (a[h][i] == x)
{
a[h].erase(a[h].begin() + i);
return;
}
}
bool Query(int x)
{
int h = x % MOD;
for (unsigned int i = 0; i < a[h].size(); i ++)
if (a[h][i] == x)
return 1;
return 0;
}
int main()
{
cin >> n;
a = vector< vector<int> >(MOD);
for (int i = 1, x, cer; i <= n; i ++)
{
cin >> cer >> x;
if (cer == 1)Add(x);
else if (cer == 2)Delete(x);
else cout << Query(x) << '\n';
}
return 0;
}