Pagini recente » Cod sursa (job #2779026) | Cod sursa (job #2772300) | Cod sursa (job #1655494) | Cod sursa (job #119658) | Cod sursa (job #1222432)
#include <fstream>
#include <vector>
#define H 1003
using namespace std;
ifstream fin("hashuri.in");
ofstream fout("hashuri.out");
vector<int> h[H];
int n,x,val,cod;
int main()
{
fin>>n;
for(;n;n--)
{
fin>>cod>>val;
x=val%H;
vector<int>::iterator it;
for(it=h[x].begin();it!=h[x].end();it++)
if(*it==val)
break;
if(cod==1)
{
if(it==h[x].end())
h[x].push_back(val);
}
else if(cod==2)
{
if(it!=h[x].end())
{
*it=h[x].back();
h[x].pop_back();
}
}
else
{
if(it==h[x].end())
fout<<"0\n";
else
fout<<"1\n";
}
}
return 0;
}