Pagini recente » Cod sursa (job #670250) | Cod sursa (job #1021306) | Cod sursa (job #800266) | Cod sursa (job #2631481) | Cod sursa (job #1757821)
#include <iostream>
#include <fstream>
#include <vector>
#include <climits>
#define DIM 100000
std::vector<int> v[DIM];
std::ofstream ofAfisare("hashuri.out");
void DoInsert(int x)
{
int cheie = x % DIM;
for (int i = 0; i < v[cheie].size(); ++i)
if (v[cheie][i] == x)
return;
v[cheie].push_back(x);
}
void DoDelete(int x)
{
int cheie = x % DIM;
for (int i = 0; i < v[cheie].size(); ++i)
if (v[cheie][i] == x)
v[cheie].erase(v[cheie].begin() + i);
}
void DoOutput(int x)
{
int cheie = x % DIM;
if (v[cheie].size())
ofAfisare << "1\n";
else
ofAfisare << "0\n";
}
int main()
{
int N, x, op;
std::ifstream ifCitire("hashuri.in");
ifCitire >> N;
for (int i = 0; i < N; ++i)
{
ifCitire >> op >> x;
if (op == 1) // Insert
DoInsert(x);
else if (op == 2)// Delete
DoDelete(x);
else if (op == 3)// Output
DoOutput(x);
}
}