Cod sursa(job #2892206)

Utilizator neagamariaMaria Neaga-Budoiu neagamaria Data 21 aprilie 2022 11:50:46
Problema Hashuri Scor 30
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 1.25 kb
#include <iostream>
#include <fstream>
#include <bits/stdc++.h>
#define mod 666013

using namespace std;

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

//matrice(indice linie=cheie)
vector <int>m[mod+1];

int n, cerinta;
long long x;

int main()
{
    in>>n;
    for(int i=0; i<n; i++)
    {
        in>>cerinta>>x;
        int l=m[x%mod].size();
        if(cerinta==1)
        {
            bool gasit=0;
            for(int j=0; j<l; j++)
                if(m[x%mod][j]==x)
                    gasit=1;
            if(gasit==0)
                m[x%mod].push_back(x);
        }
        if(cerinta==2)
        {
            for(int j=0; j<l; j++)
                if(m[x%mod][j]==x)
                {
                    int aux=m[x%mod][j];
                    m[x%mod][j]=m[x%mod][l-1];
                    m[x%mod][l-1]=aux;
                    m[x%mod].pop_back();
                }
        }
        if(cerinta==3)
        {
            bool gasit=0;
            for(int j=0; j<l; j++)
                if(m[x%mod][j]==x)
                {
                    gasit=1;
                    out<<1<<endl;
                }
            if(gasit==0)
                out<<0<<endl;
        }

    }

    return 0;
}