Cod sursa(job #2734796)

Utilizator bananamandaoneTudor Cosmin Oanea bananamandaone Data 1 aprilie 2021 13:34:03
Problema Hashuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 1.05 kb
#include <bits/stdc++.h>
#define mod 700001

using namespace std;

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

vector<int>h[mod];
int n;

void op1(int x)
{
    unsigned int i;
    for(i = 0; i < h[x % mod].size(); ++i)
        if(h[x % mod][i] == x)
            return;
    h[x % mod].push_back(x);
}

void op2(int x)
{
    unsigned int i;
    for(i = 0; i < h[x % mod].size(); ++i)
        if(h[x % mod][i] == x)
        {
            h[x % mod].erase(h[x % mod].begin() + i);
            return;
        }
}

void op3(int x)
{
    unsigned int i;
    for(i = 0; i < h[x % mod].size(); ++i)
        if(h[x % mod][i] == x)
        {
            fout << "1\n";
            return;
        }
    fout << "0\n";
}

int main()
{
    int i, op, x;

    fin >> n;

    for(i = 1; i <= n; ++i)
    {
        fin >> op >> x;

        if(op == 1)
            op1(x);
        else if(op == 2)
            op2(x);
        else
            op3(x);
    }

    fin.close();
    fout.close();
    return 0;
}