Pagini recente » Cod sursa (job #2198535) | Cod sursa (job #1972963) | Cod sursa (job #2043534) | Cod sursa (job #3145629) | Cod sursa (job #3159509)
#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;
ifstream f("hashuri.in");
ofstream g("hashuri.out");
const int b=41;
const int modulo=111119;
int hsh(int numar){
int s=0;
while(numar){
s=(s*b+numar%10)%modulo;
numar/=10;
}
return s;
}
vector<vector<int> >H;
int main()
{
int n,x,op;
H.resize(modulo+1);
f>>n;
for(int i=0; i<n; i++)
{
f>>op>>x;
int Hash=hsh(x);
vector<int>::iterator it=find(H[Hash].begin(),H[Hash].end(),x);
if(op==1 && it==H[Hash].end())
{
H[Hash].push_back(x);
}
else if(op==2 && it!=H[Hash].end())
{
H[Hash].erase(it);
}
else if (op==3)
{
if(it != H[Hash].end())
g<<1<<"\n";
else
g<<0<<"\n";
}
}
return 0;
}