Pagini recente » Rating Paraschiva Octavian Alexandru (ottoalex2008) | Cod sursa (job #1845563) | Cod sursa (job #2908744) | Cod sursa (job #424289) | Cod sursa (job #1830085)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("hashuri.in");
ofstream fout("hashuri.out");
const int PRIME = 1543;
const int R = rand()%47;
vector<int> hashTable[PRIME];
int n,x,y,pos;
inline int h(int x){return ((x*R)%PRIME);}
int main()
{
fin>>n;
for(int i=1;i<=n;i+=1)
{
fin>>x>>y;
pos=h(y);
auto getPosition = find(hashTable[pos].begin(),hashTable[pos].end(),y);
switch(x)
{
case 1:
if(getPosition==hashTable[pos].end())
hashTable[pos].push_back(y);
break;
case 2:
if(getPosition!=hashTable[pos].end())
hashTable[pos].erase(getPosition);
break;
case 3:
fout<<(getPosition!=hashTable[pos].end())<<'\n';
break;
}
}
return 0;
}