Pagini recente » Cod sursa (job #3152906) | Cod sursa (job #1906513) | Cod sursa (job #1512800) | Cod sursa (job #704954) | Cod sursa (job #3202303)
#include <fstream>
#include <vector>
using namespace std;
const int MOD = 666013;
vector<int> h[MOD];
int v[1000001];
ifstream cin("hashuri.in");
ofstream cout("hashuri.out");
bool caut(int x)
{
int cod = x % MOD, i=0;
while(i < h[cod].size() && h[cod][i] != x)
i++;
return i < h[cod].size();
}
void adaug(int x)
{
int cod = x % MOD, i=0;
while(i < h[cod].size() && h[cod][i] != x)
i++;
if(i == h[cod].size())
h[cod].push_back(x);
}
void sterg(int x)
{
int cod = x % MOD, i=0;
while(i < h[cod].size() && h[cod][i] != x)
i++;
if(i < h[cod].size())
h[cod].erase(h[cod].begin() + i);
}
int main()
{
int n, op, x, ras;
cin >> n;
for(int i=0; i<n; i++){
cin >> op >> x;
if(op == 1)
adaug(x);
else if(op == 2)
sterg(x);
else if(op == 3)
cout <<caut(x) << '\n';
}
return 0;
}