Pagini recente » Cod sursa (job #243955) | Cod sursa (job #1664909) | Cod sursa (job #1481453) | Cod sursa (job #102620) | Cod sursa (job #1058071)
#include <fstream>
#include <vector>
#include <iterator>
#define mod 666013
using namespace std;
ifstream f("hashuri.in");
ofstream g("hashuri.out");
int cautare(vector <int> H[mod],int x){
int aux = 0;
for(int i=0;i<H[x%mod].size();++i)
if(x == H[x%mod][i]){
aux = i;
break;
}
return aux;
}
void inserare(vector <int> H[mod],int x){
if(cautare(H,x) == 0)
H[x%mod].push_back(x);
}
void stergere(vector <int> H[mod],int x){
int poz = cautare(H,x);
if(poz != 0){
H[x%mod][poz] = H[x%mod].back();
H[x%mod].pop_back();
}
}
int main(){
int n,op,el;
vector <int> H[mod];
f>>n;
for(int i=0;i<n;++i){
f>>op>>el;
if(op == 1)
inserare(H,el);
else if(op == 2)
stergere(H,el);
else if(cautare(H,el) != 0)
g<<1;
else g<<0;
}
f.close();
g.close();
return 0;
}