Pagini recente » Rating Mazere Razvan (gumball.0201) | Cod sursa (job #1287330) | Cod sursa (job #1863184) | Cod sursa (job #377251) | Cod sursa (job #532292)
Cod sursa(job #532292)
#include<cstdio>
#include<vector>
#define PRM 749993
#define IT vector < int > :: iterator
using namespace std;
vector < vector < int > > a(PRM);
void solve();
void op1(int x);
void op2(int x);
IT op3(int x);
int main()
{
freopen("hashuri.in","r",stdin);
freopen("hashuri.out","w",stdout);
solve();
return 0;
}
void solve()
{
IT it;
int N,c,x;
scanf("%d",&N);
while(N)
{
scanf("%d%d",&c,&x);
if (c==1)
op1(x);
if (c==2)
op2(x);
if (c==3)
{
it=op3(x);
printf("%d\n",it!=a[x%PRM].end());
}
--N;
}
}
void op1(int x)
{
IT it;
it=op3(x);
if (it==a[x%PRM].end())
a[x%PRM].push_back(x);
}
void op2(int x)
{
IT it1,it2;
int r=x%PRM;
it1=op3(x);
if (it1!=a[r].end())
{
it2=a[r].end();
--it2;
swap(*it1,*it2);
a[r].pop_back();
}
}
IT op3(int x)
{
IT it;
int r=x%PRM;
for (it=a[r].begin();it!=a[r].end();++it)
if (*it==x) return it;
return it;
}