Pagini recente » Monitorul de evaluare | Cod sursa (job #2148964) | Profil Busik | Cod sursa (job #3247789) | Cod sursa (job #2622456)
#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) << endl;
}
f.close();
g.close();
return 0;
}