Pagini recente » Cod sursa (job #2208690) | Cod sursa (job #1242253) | Cod sursa (job #1456671) | Cod sursa (job #116842) | Cod sursa (job #1518751)
#include <fstream>
#include <vector>
#define mod 666013
#define cheie x%mod
using namespace std;
ifstream f("hashuri.in");
ofstream g("hashuri.out");
int N, tip, x;
vector <int> H[666013];
int cauta (int x)
{
for(int i = 0; i < H[cheie].size(); i ++)
if(H[cheie][i] == x) return i;
return -1;
}
void adauga (int x) { H[cheie].push_back(x); }
void sterge (int x)
{
int pozitie;
pozitie = cauta(x);
if(pozitie == - 1) return;
swap(H[cheie][pozitie], H[cheie][H[cheie].size()-1]);
H[cheie].pop_back();
}
int main ()
{
f >> N;
for(int i = 1; i <= N; i ++)
{
f >> tip >> x;
if(tip == 1) adauga(x);
if(tip == 2) sterge(x);
if(tip == 3)
{
if(cauta(x) != - 1) g << "1" << '\n';
else g << "0" << '\n';
}
}
return 0;
}