Cod sursa(job #2835722)

Utilizator AswVwsACamburu Luca AswVwsA Data 19 ianuarie 2022 10:01:55
Problema Hashuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.76 kb
#include <fstream>
#include <list>
using namespace std;

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

const int MOD = 666013;
list <int> v[MOD];
list <int> :: iterator it;
int main()
{
    int n;
    cin >> n;
    while (n--)
    {
        int op, x;
        cin >> op >> x;
        int r = x % MOD;
        bool ok = 0;
        for (it = v[r].begin(); it != v[r].end(); it++)
            if (*it == x)
            {
                ok = 1;
                break;
            }
        if (op == 1)
        {
            if (!ok)
                v[r].push_back(x);
        }
        else if (op == 2)
        {
            if (ok)
                v[r].erase(it);
        }
        else
            cout << ok << "\n";
    }
}