Pagini recente » Cod sursa (job #1996954) | Cod sursa (job #2588937) | Cod sursa (job #2411517) | Cod sursa (job #2039676) | Cod sursa (job #2622439)
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
//const int mod = 66666;
vector<int> hasht[66666];
void add(int x){
hasht[x % 66666].push_back(x);
}
void deleteh(int x){
int m = x % 66666;
for (int i = 0; i < hasht[m].size(); i++)
if(hasht[m][i] == x)
hasht[m].erase(hasht[m].begin()+i);
}
int searchh(int x){
int m = x % 66666;
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(int i = 0; i < n; i++){
f >> x >> y;
if(x == 1)
add(y);
else
if(x == 2)
deleteh(y);
else
g << searchh(y) << endl;
}
f.close();
g.close();
return 0;
}