Pagini recente » Cod sursa (job #2335440) | Cod sursa (job #1480823) | Cod sursa (job #230416) | Cod sursa (job #2713515) | Cod sursa (job #2626143)
#include <bits/stdc++.h>
#define MOD 642643
using namespace std;
int N,i,j,op,x;
vector<int> vect[MOD];
vector<int>::iterator find_val(int x)
{
int hashed = x%MOD;
for(auto it = vect[hashed].begin(); it != vect[hashed].end(); ++it)
if(*it == x)
return it;
return vect[hashed].end();
}
void insert_val(int x)
{
int hashed = x % MOD;
if(find_val(x) == vect[hashed].end())
vect[hashed].push_back(x);
}
void erase_val(int x)
{
int hashed = x % MOD;
auto it = find_val(x);
if (it != vect[hashed].end())
vect[hashed].erase(it);
}
int main()
{
ifstream f("hashuri.in");
ofstream g("hashuri.out");
f>>N;
for(i=0;i<N;i++)
{
f>>op>>x;
switch(op)
{
case 1:
insert_val(x);
break;
case 2:
erase_val(x);
break;
case 3:
g<< (find_val(x) != vect[x%MOD].end()) << "\n";
break;
}
}
f.close();
g.close();
return 0;
}