Pagini recente » Cod sursa (job #1043890) | Cod sursa (job #2617606) | Cod sursa (job #2717909) | Cod sursa (job #320181) | Cod sursa (job #2892159)
#include <iostream>
#include <fstream>
#include <vector>
#define PRIME 999983
using namespace std;
vector<int> v[PRIME];
int cauta(const int &x,bool sterge){
for(auto i=v[x%PRIME].begin();i!=v[x%PRIME].end();++i){
if(*i==x){
if(sterge){
v[x%PRIME].erase(i);
}
return 1;
}
}
return 0;
}
int main(){
ifstream f("hashuri.in");
ofstream g("hashuri.out");
int n,op,x;
f>>n;
for(int i=0;i<n;++i){
f>>op>>x;
if(op==1){
if(!cauta(x,false))
v[x%PRIME].push_back(x);
}
else
if(op==2)
cauta(x,true);
else
g<<cauta(x,false)<<'\n';
}
return 0;
}