Cod sursa(job #2886066)

Utilizator VladTalpigaVlad Talpiga VladTalpiga Data 6 aprilie 2022 22:11:52
Problema Hashuri Scor 60
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.89 kb
#include <iostream>
#include <vector>
#include <fstream>

using namespace std;

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

#define k 666013

vector <int> hashh[k+5];

int main()
{
int n, i, j, x, y, clasa, poz, ok;

f>>n;

for(i = 1; i <= n; i++)
    {

    f>>y>>x;

    ok = 0;

    clasa = x % k;

    for(j = 0; j < hashh[clasa].size(); j++)
    {
            if(hashh[clasa][j] == x)
            {

                ok = 1;
                poz = j;
                break;
            }
    }

    if(y == 1)
    {
        if(ok == 0)

            hashh[clasa].push_back(x);

    }
    else
    {
    if(y == 2)
    {
        if(ok == 1)
        {
            swap(hashh[clasa][poz], hashh[clasa].back());
            hashh[clasa].pop_back();
        }


    }
    else
        {

        g<<ok<<endl;

    }}

}


    return 0;
}