Pagini recente » Cod sursa (job #2141112) | Cod sursa (job #2799805) | Cod sursa (job #2476719) | Cod sursa (job #99757) | Cod sursa (job #1050264)
#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
std::ifstream fin("hashuri.in");
std::ofstream fout("hashuri.out");
int n;
std::vector<int> hashuri[666013];
inline int cauta(int &poz, int &val)
{
for(int i = 0; i < hashuri[poz%666013].size(); i++)
{
if(hashuri[poz%666013][i] == val)
{
return i;
}
}
return -1;
}
void citire()
{
int x, y;
fin>>n;
for(int i = 0; i < n; i++)
{
fin>>x>>y;
if(x == 1)
{
if(cauta(y, y) == -1)
{
hashuri[y%666013].push_back(y);
}
}
else
if(x == 2)
{
int poz = cauta(y, y);
if(poz != -1)
{
hashuri[y%666013][poz] = hashuri[y%666013].back();
hashuri[y%666013].pop_back();
}
}
else
{
if(cauta(y, y) != -1)
{
fout<<1<<'\n';
}
else
{
fout<<0<<'\n';
}
}
}
}
int main()
{
citire();
return 0;
}