Cod sursa(job #2211081)

Utilizator AlexandruabcdeDobleaga Alexandru Alexandruabcde Data 9 iunie 2018 12:55:56
Problema Hashuri Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.98 kb
#include <fstream>
#include <vector>
#define Mod 666013

using namespace std;

ifstream f ("hashuri.in");
ofstream g ("hashuri.out");

vector <int> G[666014];

int n, cer, x;
int main()
{
    f >> n;
    for (int i = 1; i <= n; i++)
    {
        f >> cer >> x;
        if (cer == 1)
        {
            G[x%Mod].push_back(x);
        }
        else if (cer == 2)
        {
            for (int j = 0; j < G[x%Mod].size(); j++)
            {
                if (G[x%Mod][j] == x)
                {
                    G[x%Mod][j] = -1;
                }
            }
        }
        else
        {
            bool ok = false;
            for (int j = 0; j < G[x%Mod].size(); j++)
            {
                if (G[x%Mod][j] == x)
                {
                    ok = true;
                    break;
                }
            }

            if (ok == true) g << 1 << '\n';
            else g << 0 << '\n';
        }
    }
    return 0;
}