Pagini recente » Cod sursa (job #2628959) | Cod sursa (job #1272474) | Cod sursa (job #1425172) | Cod sursa (job #2202611) | Cod sursa (job #2771515)
#include <bits/stdc++.h>
#define key 666013
using namespace std;
vector <int> htable[key];
int n, t, x;
bool check(int value)
{
int hvalue = value % key;
for(int i = 0; i < htable[hvalue].size(); i++)
{
if(htable[hvalue][i] == value)
{
return 1;
}
}
return 0;
}
void add(int value)
{
if(check(value))
{
return;
}
int hvalue = value % key;
htable[hvalue].push_back(value);
}
void del(int value)
{
int hvalue = value % key;
for(int i = 0; i < htable[hvalue].size(); i++)
{
if(htable[hvalue][i] == value)
{
swap(htable[hvalue][i], htable[hvalue][htable[hvalue].size() - 1]);
htable[hvalue].pop_back();
}
}
}
int main()
{
ifstream fin("hashuri.in");
ofstream fout("hashuri.out");
fin>>n;
for(int i = 1; i <= n; i++)
{
fin>>t>>x;
if(t == 1)
add(x);
else
if(t == 2)
del(x);
else
fout<<check(x)<<'\n';
}
return 0;
}