Pagini recente » Cod sursa (job #766357) | Cod sursa (job #653766) | Cod sursa (job #2495412) | Istoria paginii runda/infonatafleata | Cod sursa (job #1318596)
#include <bits/stdc++.h>
using namespace std;
vector<int> v[700000];
int k,p = 666103,a,q;
int b;
//
void insertElement(int f)
{
for(int i = 0 ; i < v[q].size(); i++)
{
if(v[q][i] == f) return;
}
v[q].push_back(f);
}
bool isInSet(int f)
{
for(int i = 0 ; i < v[q].size() ; i++)
if(v[q][i] == f) return true;
return false;
}
void erase_hash(int f)
{
int lim = v[q].size();
for(int i = 0 ; i < lim; i++)
{
if(v[q][i] == f)
{
v[q][i] = v[q][lim-1];
v[q].pop_back();
return;
}
}
}
int main()
{
freopen("hashuri.in", "r", stdin);
freopen("hashuri.out", "w", stdout);
cin >> k;
for(int i = 0 ; i < k; i++)
{
cin >> a >> b;
q = b%p;
if(a == 1)
{
insertElement(b);
}
if(a == 2)
{
erase_hash(b);
}
if(a == 3)
{
cout << (isInSet(b)) ? "1" : "0";
cout << "\n";
}
}
return 0;
}