Pagini recente » Cod sursa (job #2490335) | Cod sursa (job #582050) | Cod sursa (job #2550902) | Utilizatori inregistrati la ONIS 2015, Runda 2 | Cod sursa (job #348362)
Cod sursa(job #348362)
#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);
}
}
}
int main()
{
return 0;
}