Pagini recente » Cod sursa (job #2443706) | Cod sursa (job #2963375) | Cod sursa (job #2731907) | Cod sursa (job #2613708) | Cod sursa (job #2744675)
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
ifstream f("hashuri.in");
ofstream g("hashuri.out");
int n,operatie;
long x;
vector<long> h[10000];
/*
int hash_func(int x){
return x%97;
}
*/
int index(long x){
int poz = x%997;
for(int i=0;i<h[poz].size();i++){
if(h[poz][i] == x){
h[poz][i] = 0;
return 1;
}
}
return 0;
}
void push(long x){
//int poz = hash_func(x);
if(!index(x)){
h[x%997].push_back(x);
}
}
void pop(long x){
int poz = x%997;
for(int i=0;i<h[poz].size();i++){
if(h[poz][i] == x){
h[poz].erase(h[poz].begin() + i);
}
}
}
int main(){
f>>n;
for(int i=0;i<n;i++){
f>>operatie>>x;
if(operatie == 1) push(x);
if(operatie == 2) pop(x);
if(operatie == 3) g<<index(x)<<'\n';
}
return 0;
}