Pagini recente » Cod sursa (job #2376540) | Cod sursa (job #1144409) | Cod sursa (job #2189751) | Cod sursa (job #949548) | Cod sursa (job #348364)
Cod sursa(job #348364)
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
#define PRIM 666203
vector<int > H[PRIM];
int check(int temp)
{
vector<int >::iterator it;
for (it=H[temp%PRIM].begin(); it<H[temp%PRIM].end(); it++)
if (*it == temp)
return 1;
return 0;
}
void del(int temp)
{
int i;
for (i=0; i<=H[temp%PRIM].size()-1; ++i)
if (H[temp%PRIM][i] == temp)
return;
swap (H[temp%PRIM][i], H[temp%PRIM][H[temp%PRIM].size()-1]);
H[temp%PRIM].pop_back();
}
void solve()
{
fstream f("hashuri.in", ios::in);
fstream g("hashuri.out", ios::out);
int n, aux, temp;
f>>n;
for (int i=1; i<=n; ++i)
{
f>>aux;
if (aux == 1)
{
f>>temp;
if (check(temp) == 0)
H[temp%PRIM].push_back(temp);
}
if (aux == 2)
{
f>>temp;
del(temp);
}
if (aux == 3)
{
f>>temp;
g<<check(temp)<<"\n";
}
}
f.close();
g.close();
}
int main()
{
return 0;
}