Pagini recente » Cod sursa (job #445498) | Cod sursa (job #2585773) | Cod sursa (job #3171038) | Cod sursa (job #1652164) | Cod sursa (job #1347220)
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
ifstream in ("hashuri.in");
ofstream out ("hashuri.out");
const int MOD = 666013;
vector <int> H[MOD];
void Insert (int x)
{
H[x % MOD].push_back (x);
}
void Erase (int x)
{
vector <int> :: iterator it;
int now = x % MOD;
for (it = H[now].begin (); it != H[now].end (); ++ it)
if (*it == x){
H[now].erase (it);
return;
}
}
bool Find (int x)
{
vector <int> :: iterator it;
int now = x % MOD;
for (it = H[now].begin (); it != H[now].end (); ++ it)
if (*it == x)
return 1;
return 0;
}
int main()
{
int N, op, x;
in >> N;
while (N --){
in >> op >> x;
if (op == 1)
Insert (x);
if (op == 2)
Erase (x);
if (op == 3)
if (Find (x))
out << "1\n";
else
out << "0\n";
}
return 0;
}