Pagini recente » Cod sursa (job #561227) | Cod sursa (job #862152) | Cod sursa (job #2205254) | Cod sursa (job #2660825) | Cod sursa (job #2601297)
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
#define MOD 666013
int N;
vector<int> G[MOD];
inline vector<int>::iterator find_value(int x)
{
int list = x % MOD;
vector<int>::iterator it;
for (it = G[list].begin(); it != G[list].end(); ++it)
if (*it == x)
return it;
return G[list].end();
}
inline void insert_value(int x)
{
int list = x % MOD;
if (find_value(x) == G[list].end())
G[list].push_back(x);
}
inline void erase_value(int x)
{
int list = x % MOD;
vector<int>::iterator it = find_value(x);
if (it != G[list].end())
G[list].erase(it);
}
int main()
{
int t;
int x;
ifstream fin("hashuri.in");
ofstream fout("hashuri.out");
fin>>N;
for(int i= 0;i<N;i++){
fin>>t;
fin>>x;
if(t==1){
insert_value(x);
continue;
}
if(t==2){
erase_value(x);
continue;
}
fout<<(find_value(x) != G[x%MOD].end())<<endl;
}
}