Cod sursa(job #873016)

Utilizator mihai27Mihai Popescu mihai27 Data 6 februarie 2013 20:12:08
Problema Hashuri Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.79 kb
#include<fstream>
#include<vector>

using namespace std;

ifstream in("hashuri.in");
ofstream out("hashuri.out");

int n,i,x,y;
vector<int> a[100000];
vector<int>::iterator it;

int find(int x)
{
    for (it=a[x%99999].begin();it!=a[x%99999].end();it++)
        if (*it==x) return 1;
    return 0;
}

void add(int x)
{
    a[x%99999].push_back(x);
}

void remove(int x)
{
    for (it=a[x%99999].begin();it!=a[x%99999].end();it++)
        if (*it==x)
        {
            a[x%99999].erase(it);
            return;
        }
}

int main()
{
    in>>n;
    for (i=1;i<=n;i++)
    {
        in>>x>>y;
        if (x==1) if (!find(y)) add(y);
        if (x==2) if (find(y)) remove(y);
        if (x==3) if (find(y)) out<<"1\n";
            else out<<"0\n";
    }

}