Pagini recente » Profil Ramona2007 | Monitorul de evaluare | Profil eudanip | 1-2-3-4-5-6-7-8-9 | Cod sursa (job #1774549)
#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
#include <iterator>
using namespace std;
const int hsize = 65000;
vector < vector<unsigned int> > h(hsize);
void remove(unsigned int x) {
int i = x / hsize;
vector<unsigned int>::iterator pos = find(h[i].begin(), h[i].end(), x);
if(pos!=h[i].end()) {
h[i].erase(pos);
}
}
void put(unsigned int x) {
int i = x / hsize;
h[i].push_back(x);
}
bool get(unsigned int x) {
int i = x / hsize;
vector<unsigned int>::iterator pos = find(h[i].begin(), h[i].end(), x);
return pos != h[i].end();
}
int main() {
ifstream cin("hashuri.in");
ofstream cout("hashuri.out");
unsigned int n, op, x;
cin>>n;
for (int i = 0; i < n; i++) {
cin>>op>>x;
if (op == 1) {
put(x);
} else if (op == 2) {
remove(x);
} else {
cout<<get(x)<<"\n";
}
}
}