Pagini recente » Cod sursa (job #156261) | Cod sursa (job #244795) | Cod sursa (job #255525) | Cod sursa (job #842664) | Cod sursa (job #2894085)
#include <iostream>
#include <fstream>
#include <vector>
#define nrmare 666013
using namespace std;
ifstream f("hashuri.in");
ofstream g("hashuri.out");
vector<int> hashuri[nrmare];
bool cautare(int x){
for(auto i = hashuri[x%nrmare].begin(); i!=hashuri[x%nrmare].end();i++) {
if (*i == x)
return 1;
}
return 0;
}
void stergere(int x) {
for (auto i = hashuri[x % nrmare].begin(); i != hashuri[x % nrmare].end(); i++) {
if (*i == x) {
hashuri[x % nrmare].erase(i);
i = hashuri[x % nrmare].end();
}
}
}
void adaugare(int x) {
if (!cautare(x)) {
hashuri[x%nrmare].push_back(x);
}
}
int main() {
int i;
f>>i;
while(i>=0){
cout<<1;
int aux,x;
f>>aux>>x;
if(aux == 1){
adaugare(x);
}
if(aux == 2){
stergere(x);
}
if(aux == 3){
g<<cautare(x)<<'\n';
}
--i;
}
return 0;
}