Cod sursa(job #3131349)

Utilizator iulia_tamasTamas Iulia iulia_tamas Data 19 mai 2023 21:49:37
Problema Hashuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 1.07 kb
#include <bits/stdc++.h>
using namespace std;

ifstream fin("hashuri.in");
ofstream fout("hashuri.out");
const int n=1000002;
vector<int> v[n];
int main()
{
    int n,optiune,x,y;
    fin>>n;
    for(int i=0; i<n; i++){
        fin>>optiune>>x;
        switch(optiune){
        case 1:{
            y=x%1000002;
            auto gasit = find(v[y].begin(),v[y].end(),x);
            if(gasit == v[y].end())
                v[y].push_back(x);
            break;}
        case 2:{
            y=x%1000002;
            auto gasit = find(v[y].begin(),v[y].end(),x);
                if(gasit != v[y].end()){
                    int poz=distance(v[y].begin(), gasit);
                    v[y].erase(v[y].begin()+poz);
                }
            break;}
        case 3:{
            y=x%1000002;
            auto gasit = find(v[y].begin(),v[y].end(),x);
                if(gasit != v[y].end()){
                    fout<<1<<endl;
                }
                else
                    fout<<0<<endl;
            break;}

        }

    }
    return 0;
}