Pagini recente » Cod sursa (job #2671035) | Cod sursa (job #1251899) | Cod sursa (job #1860099) | Cod sursa (job #2918703) | Cod sursa (job #1017935)
#include<iostream>
#include<fstream>
#include<vector>
using namespace std;
#define mod 666013
int find(vector<int> V[mod], int x){
int index = x%mod;
for (vector<int>::iterator i = V[index].begin(); i != V[index].end(); i++){
if (*i == x){
return 1;
}
}
return 0;
}
bool insert(vector<int> V[mod], int x){
if (find(V, x) == 0){
V[x%mod].push_back(x);
return true;
}
return false;
}
bool sterge(vector<int> V[mod], int x){
int index = x%mod;
for (vector<int>::iterator i = V[index].begin(); i != V[index].end(); i++){
if (*i == x){
V[index].erase(i);
return true;
}
}
return false;
}
int main(){
fstream f("hashuri.in");
ofstream o("hashuri.out");
vector<int> hash[mod];
int n = 0; f >> n;
int op = 0, x = 0;
for (int i = 0; i < n; i++){
f >> op >> x;
if (op == 1){
insert(hash, x);
}
else if (op == 2){
sterge(hash, x);
}
else if (op == 3){
o << find(hash, x) << "\n";
}
}
}