Pagini recente » Cod sursa (job #2560843) | Cod sursa (job #639628) | Cod sursa (job #2028424) | Cod sursa (job #2447067) | Cod sursa (job #2747838)
#include <iostream>
#include <fstream>
#include <vector>
#include <iterator>
using namespace std;
vector<int> hash[666013];
vector<int>::iterator find(int x){
int key=x%666013;
vector<int>::iterator i;
for (i=hash[key].begin();i!=hash[key].end();i++)
if (*i==x)
return i;
return hash[key].end();
}
int found(int x){
int key=x%666013;
if (find(x)==hash[key].end())
return 0;
return 1;
}
void add(int x){
int key=x%666013;
if (find(x)==hash[key].end())
hash[key].push_back(x);
}
void remove(int x){
int key=x%666013;
vector<int>::iterator i = find(x);
if (i!=hash[key].end())
hash[key].erase(i);
}
int main(){
int n,x,val;
ifstream f("hashuri.in");
ofstream g("hashuri.out");
f>>n;
for (int i=1;i<=n;i++){
f>>x;
f>>val;
if (x==1){
add(val);
}
else if (x==2){
remove(val);
}
else if(x==3)
g<<found(val)<<'\n';
}
return 0;
}