Pagini recente » Cod sursa (job #2034784) | Cod sursa (job #2027096) | Cod sursa (job #964069) | Clasament oni-2009-xi-xii | Cod sursa (job #2895587)
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
ifstream in("hashuri.in");
ofstream out("hashuri.out");
const int val_hash = 600000;
vector<int> vhash[val_hash];
int n, op, val;
bool gasit;
int main() {
in>>n;
unsigned int i;
for (i = 0; i < n; i++)
{
in>>op>>val;
int poz = val % val_hash;
gasit = 0;
if (op == 1)
{
for (i = 0 ; i < vhash[poz].size() && !gasit; i++)
if (vhash[poz][i] == val)
gasit = 1;
if (!gasit)
vhash[poz].push_back(val);
}
if (op == 2)
{
for (i = 0 ; i < vhash[poz].size() && !gasit; i++)
if (vhash[poz][i] == val){
vhash[poz][i] = 0;
gasit = 1;
}
}
if(op == 3)
{
for (i = 0 ; i < vhash[poz].size() && !gasit; i++)
if (vhash[poz][i] == val)
gasit = 1;
if (gasit)
out<<1<<endl;
else out<<0<<endl;
}
}
}