Pagini recente » Istoria paginii runda/emagcluj_9_2016/clasament | Rating Boboc Razvan (rzvn) | Cod sursa (job #1375230) | Cod sursa (job #535171) | Cod sursa (job #640487)
Cod sursa(job #640487)
#include <fstream>
#include <vector>
#define MOD 666013
using namespace std;
int n;
vector<int> t_hash[MOD];
typedef vector<int>::iterator it;
ifstream f("hashuri.in");
ofstream g("hashuri.out");
void citeste(){
f>>n;
}
it afla_iterator(int x){
int h_x = x % MOD;
for(it i=t_hash[h_x].begin(); i != t_hash[h_x].end(); ++i){
if (*i == x)
return i;
}
return t_hash[h_x].end();
}
void sterge(int x){
it ite = afla_iterator(x);
int h_x = x % MOD;
if (ite != t_hash[h_x].end())
t_hash[h_x].erase(ite);
}
void adauga(int x){
it ite = afla_iterator(x);
int h_x = x % MOD;
if (ite == t_hash[h_x].end())
t_hash[h_x].push_back(x);
}
void rezolva(){
for(int i=1; i<=n; ++i){
int x,y;
f>>x>>y;
if (x == 1){
adauga( y );
}else if (x == 2){
sterge( y );
}else if (x == 3){
int h_x = y % MOD;
if (afla_iterator(y) == t_hash[h_x].end())
g<<"0"<<"\n";
else g<<"1"<<"\n";
}
}
}
int main(){
citeste();
rezolva();
f.close();
g.close();
return 0;
}