Pagini recente » Cod sursa (job #1928893) | Cod sursa (job #2228342) | Cod sursa (job #2570083) | Cod sursa (job #749676) | Cod sursa (job #2747970)
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
const int mod = 386621;
int N, op;
vector<int> v[mod];
int findv(int x)
{
int x_h = x % mod;
for (int i = 0; i < v[x_h].size(); i++)
if (v[x_h][i] == x)
return 1;
return 0;
}
void insertv(int x)
{
int x_h = x % mod;
if (findv(x) == 0)
v[x_h].push_back(x);
}
void deletev(int x)
{
int x_h = x % mod;
for (int i = 0; i < v[x_h].size(); i++)
if (v[x_h][i] == x)
{
v[x_h][i] = v[x_h][v[x_h].size() - 1];
v[x_h].pop_back();
break;
}
}
int main()
{
ifstream f("hashuri.in");
ofstream o("hashuri.out");
int x;
f >> N;
for (int i = 0; i < N; i++)
{
f >> op >> x;
if (op == 1)
insertv(x);
if (op == 2)
deletev(x);
if (op == 3)
o<<findv(x)<<endl;
}
}