Pagini recente » Utilizatori inregistrati la Tiberiu Popoviciu 2011, Clasele 11-12 | Clasament c1 | Clasament brasov_11_jr | Istoria paginii runda/autumn19/clasament | Cod sursa (job #1774552)
#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
#include <iterator>
using namespace std;
const int hsize = 45119;
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";
}
}
}