Cod sursa(job #3328685)

Utilizator ccris.29Chirila Cristian ccris.29 Data 9 decembrie 2025 17:41:06
Problema Hashuri Scor 60
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 1.71 kb
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;

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

int n, op, x, ok;
const int MOD = 666013;
vector<int> H[MOD];

int main()
{
    fin >> n;

    for (int i = 1; i <= n; i++)
    {
        fin >> op >> x;
        // cout << op << " " << x << "\n";
        ok = 0;
        if (op == 1)
        {
            // cout << op << " " << x << "\n";
            for (int j = 0; j < H[x % MOD].size(); j++)
            {
                // cout << 'a' << "\n";
                if (H[x % MOD][j] == x)
                {
                    // cout << 'a' << "\n";
                    ok = 1;
                    break;
                }
            }
            if (ok == 0)
                H[x % MOD].push_back(x);
        }
        // cout << 'a' << "\n";
        if (op == 2)
        {
            //  cout << op << " " << x << "\n";
            for (int j = 0; j < H[x % MOD].size(); j++)
                if (H[x % MOD][j] == x)
                {
                    while (j + 1 < H[x % MOD].size())
                    {
                        H[x % MOD][j] = H[x % MOD][j + 1];
                    }
                    H[x % MOD].pop_back();
                    break;
                }
        }
        if (op == 3)
        {
            //  cout << op << " " << x << "\n";
            for (int j = 0; j < H[x % MOD].size(); j++)
                if (H[x % MOD][j] == x)
                {
                    fout << 1 << " \n";
                    ok = 1;
                    break;
                }
            if (ok == 0)
                fout << 0 << "\n";
        }
    }

    return 0;
}