Pagini recente » Cod sursa (job #2324220) | Cod sursa (job #2185806) | Cod sursa (job #2279092) | Cod sursa (job #1421517) | Cod sursa (job #999494)
Cod sursa(job #999494)
#include<fstream>
#include<vector>
#define mod 666013
using namespace std;
ifstream in("hashuri.in");
ofstream out("hashuri.out");
int n,i,c,x,a,b;
vector<int> v[mod];
inline vector<int>::iterator find_value(int x)
{
int list = x % mod;
vector<int>::iterator it;
for (it = v[list].begin(); it != v[list].end(); ++it)
if (*it == x)
return it;
return v[list].end();
}
inline void insert_value(int x)
{
int list = x % mod;
if (find_value(x) == v[list].end())
v[list].push_back(x);
}
inline void erase_value(int x)
{
int list = x % mod;
vector<int>::iterator it = find_value(x);
if (it != v[list].end())
v[list].erase(it);
}
int main ()
{
in>>n;
for(i=1;i<=n;i++){
in>>c>>x;
if(c==1){
insert_value(x);}
if(c==2){
erase_value(x);}
if(c==3){
if ( find_value(x) != v[x % mod].end() )
out<<1<<'\n';
else
out<<0<<'\n';
}
}
in.close();
out.close();
return 0;
}