Cod sursa(job #2734784)

Utilizator bananamandaoneTudor Cosmin Oanea bananamandaone Data 1 aprilie 2021 13:08:57
Problema Hashuri Scor 30
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.97 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;

int main()
{
    int i, j, op, x, da;
    fin >> n;
    for(i = 1; i <= n; i++)
    {
        fin >> op;
        fin >> x;


        if(op == 1)
            h[x % mod].push_back(x);

        if (op == 2)
        {
            for(j = 0; j < h[x % mod].size(); j++)
                if(x == h[x][j])
                {
                    h[x % mod].erase(h[x % mod].begin() + j);
                    break;
                }
        }

        if(op == 3)
        {
            da = 0;
            for(j = 0; j < h[x % mod].size(); j++)
                if(x == h[x][j])
                {
                    da = 1;
                    break;
                }
            if(da == 1)
                fout << "1\n";
            else
                fout << "0\n";
        }
    }
    return 0;
}