Pagini recente » Cod sursa (job #1897055) | Cod sursa (job #1721163) | Cod sursa (job #2729769) | Cod sursa (job #2229920) | Cod sursa (job #2747849)
#include <fstream>
#include <vector>
#include <iterator>
using namespace std;
vector<int> h[666013];
vector<int>::iterator find(int x){
int key=x%666013;
vector<int>::iterator i;
for (i=h[key].begin();i!=h[key].end();i++)
if (*i==x)
return i;
return h[key].end();
}
int found(int x){
int key=x%666013;
if (find(x)==h[key].end())
return 0;
return 1;
}
void add(int x){
int key=x%666013;
if (find(x)==h[key].end())
h[key].push_back(x);
}
void del(int x){
int key=x%666013;
vector<int>::iterator i = find(x);
if (i!=h[key].end())
h[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){
del(val);
}
else if(x==3)
g<<found(val)<<'\n';
}
return 0;
}