Pagini recente » Cod sursa (job #951801) | Cod sursa (job #2819811) | Cod sursa (job #2732567) | Cod sursa (job #797317) | Cod sursa (job #2819493)
#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;
ifstream fin("hashuri.in");
ofstream fout("hashuri.out");
int n;
const int mod=666013;
int base=97;
vector <int> H[mod+5];
int Hash(int x)
{
int rasp=0;
int p=1;
while(x!=0)
{
int cif=x%10;
x=x/10;
rasp=rasp+cif*p;
p*=base;
}
return rasp;
}
int main()
{
fin>>n;
for(int i=1;i<=n;i++)
{
int op, x;
fin>>op>>x;
int hash_nr=Hash(x);
auto it=find(H[hash_nr].begin(),H[hash_nr].end(),x);
if(op==1)
{
if(it==H[hash_nr].end())
H[hash_nr].push_back(x);
}
else if(op==2)
{
if(it!=H[hash_nr].end())
H[hash_nr].erase(it);
}
else
{
if(it!=H[hash_nr].end())
fout<<1<<'\n';
else
fout<<0<<'\n';
}
}
return 0;
}