Pagini recente » Cod sursa (job #1908686) | Cod sursa (job #1325173) | Cod sursa (job #2379090) | Cod sursa (job #1627989) | Cod sursa (job #1757820)
#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;
ofAfisare << v[cheie].size() ? '1' : '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);
}
}