Pagini recente » Cod sursa (job #2218994) | Cod sursa (job #3176788) | Cod sursa (job #1433934) | Cod sursa (job #188268) | Cod sursa (job #2622457)
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
vector<int> hasht[66013];
void Add(int x){
hasht[x % 66013].push_back(x);
}
void Delete(int x){
int m = x % 66013;
for (int i = 0; i < hasht[m].size(); i++)
if(hasht[m][i] == x)
hasht[m].erase(hasht[m].begin()+i);
}
int Search(int x){
int m = x % 66013;
for (int i = 0; i < hasht[m].size(); i++)
if(hasht[m][i] == x)
return 1;
return 0;
}
int main()
{
ifstream f("hashuri.in");
ofstream g("hashuri.out");
int n, x, y;
f>>n;
for(; n; n--){
f >> x >> y;
if(x == 1)
Add(y);
else
if(x == 2)
Delete(y);
else
g << Search(y) << '\n';
}
f.close();
g.close();
return 0;
}