Cod sursa(job #3198100)

Utilizator aeandreescuAndreescu Ana-Eliza aeandreescu Data 28 ianuarie 2024 13:03:39
Problema Hashuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.72 kb
#include <algorithm>
#include <fstream>
#include <vector>

using namespace std;

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

const int mod= 666013;

vector<int> v[mod];

int main() {
    int n;
    fin>>n;

    for ( int i= 0, a, x; i<n; ++i ) {
        fin>>a>>x;
        auto it= find(v[x%mod].begin(), v[x%mod].end(), x);

        if ( a==1 && it==v[x%mod].end() ) {
            v[x%mod].push_back(x);
        } else if ( a==2 && it!=v[x%mod].end() ) {
            v[x%mod].erase(it);
        } else if ( a==3 ) {
            if ( it!=v[x%mod].end() ) {
                fout<<"1\n";
            } else {
                fout<<"0\n";
            }
        }
    }

    return 0;
}