Cod sursa(job #2670544)

Utilizator alexia208160Popescu Alexia Maria alexia208160 Data 10 noiembrie 2020 10:29:22
Problema Hashuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.88 kb
#include <fstream>
#include <vector>

using namespace std;

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

const int mod = 818959;

vector <int> v[mod];

int main()
{
    int n;
    fin >> n;
    for(int i = 0; i < n; i++)
    {
        int c, x;
        fin >> c >> x;
        if(c == 1)
        {
            v[x % mod].push_back(x);
        }
        if(c == 2)
        {
            int nr = x % mod;
            for(int j = 0; j < v[nr].size(); j++)
                if(v[nr][j] == x)
                    v[nr][j] = -1;
        }
        if(c == 3)
        {
            int nr = x % mod;
            bool ok = 0;
            for(int j = 0; j < v[nr].size(); j++)
                if(v[nr][j] == x)
                {
                    ok = 1;
                    break;
                }
            fout << ok << '\n';
        }
    }
}