Pagini recente » Cod sursa (job #2118426) | Cod sursa (job #1391955) | Cod sursa (job #1673817) | Cod sursa (job #2366990) | Cod sursa (job #2617431)
#include <bits/stdc++.h>
using namespace std;
ifstream f("hashuri.in");
ofstream g("hashuri.out");
int n;
const int Max = 2000000;
vector<int> H[Max];
int cauta(int x)
{
for(int i = 0; i < H[x % Max].size(); i++)
if(H[x % Max][i] == x)
return i;
return -1;
}
void inserare(int x)
{
if(cauta(x) == -1)
H[x % Max].push_back(x);
}
void stergere(int x)
{
if(cauta(x) != -1)
H[x % Max].erase(H[x % Max].begin() + cauta(x));
}
int main()
{
f >> n;
int x, op;
for(int i = 0; i < n; i++)
{
f >> op >> x;
if(op == 1)
inserare(x);
else if(op == 2)
stergere(x);
else if(op == 3)
g << (cauta(x)!= -1) << '\n';
}
return 0;
}