Pagini recente » Cod sursa (job #2593424) | Cod sursa (job #911352) | Cod sursa (job #2593195) | Cod sursa (job #1578489) | Cod sursa (job #916799)
Cod sursa(job #916799)
#include<vector>
#include<algorithm>
#include<cstdio>
#define MOD 660013
FILE *f=fopen("hashuri.in","r");
FILE *g=fopen("hashuri.out","w");
using namespace std;
int n,type;
vector <int> list[MOD];
inline vector<int>::iterator find(int x)
{
int pos=x%MOD;
vector<int>::iterator it;
for(it=list[pos].begin();it!=list[pos].end(); ++it )
if(*it == x )
return it;
return list[pos].end();
}
void insert ( int x )
{
int pos=x%MOD;
if(find(x) == list[pos].end())
list[pos].push_back(x);
}
void erase( int x)
{
int pos=x%MOD;
vector <int>::iterator it;
it=find(x);
if(it!=list[pos].end())
list[pos].erase(it);
}
int main( void )
{
fscanf(f,"%d",&n);
for(int i(1); i <= n ; ++i )
{
int x;
fscanf(f,"%d%d",&type,&x);
if(type ==1 )
{
insert(x);
continue;
}
if(type == 2)
{
erase(x);
continue;
}
if(type == 3 )
{
fprintf(g,"%d\n",find(x)!=list[x%MOD].end());
}
}
fclose(f);
fclose(g);
return 0;
}