Pagini recente » Cod sursa (job #3219074) | Cod sursa (job #2650844) | Cod sursa (job #2536440) | Cod sursa (job #740131) | Cod sursa (job #641698)
Cod sursa(job #641698)
#include <fstream>
#include <vector>
const int P = 666013;
using namespace std;
vector <int> V[1000000%P];
inline vector <int>::iterator find(int x)
{
vector <int>::iterator it;
int list=x%P;
for (it=V[list].begin(); it!=V[list].end(); ++it)
if (*it==x)
return it;
return V[list].end();
}
inline void insert(int x)
{
int list=x%P;
if (find(x)==V[list].end())
V[list].push_back(x);
}
inline void erase(int x)
{
vector <int>::iterator it = find(x);
int list=x%P;
if (it!=V[list].end())
V[list].erase(it);
}
int main(int argc, char *argv[])
{
int n,op,x;
ifstream f("hashuri.in");
ofstream g("hashuri.out");
f>>n;
for (int i=0; i<n; ++i)
{
f>>op>>x;
if (op==1)
insert(x);
if (op==2)
erase(x);
if (op==3)
g<<(find(x)!=V[x%P].end())<<'\n';
}
return EXIT_SUCCESS;
}