Cod sursa(job #3129150)

Utilizator TheGodFather2131Alexandru Miclea TheGodFather2131 Data 12 mai 2023 21:28:55
Problema Hashuri Scor 70
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 1.42 kb
//ALEXANDRU MICLEA

#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <queue>
#include <map>
#include <set>
#include <unordered_map>
#include <time.h>
#include <iomanip>
#include <deque>
#include <math.h>
#include <cmath>
#include <assert.h>
#include <stack>
#include <bitset>
#include <random>
#include <chrono>
#include <iostream>
#include <fstream>
#include <array>

using namespace std;

typedef long long ll;
const ll MOD = 1e9 + 7;
#define llinf 2e18
#define iinf 1e9

//VARIABLES

vector<int> v[666015];
int mod = 666013;
int n;

//FUNCTIONS

void insert(int val) {
    for (auto& x : v[val % mod]) {
        if (x == val) return;
    }
    v[val % mod].push_back(val);
}

void remove(int val) {
    vector <int> aux;
    for (auto& x : v[val % mod]) {
        if (x != val){
            aux.push_back(x);
        }
    }

    v[val % mod] = aux;
}

int search(int val) {
    for (auto& x : v[val % mod]) {
        if (x == val) {
            return 1;
        }
    }
    return 0;
}

//MAIN
int main() {

#ifdef INFOARENA
    freopen("hashuri.in", "r", stdin);
    freopen("hashuri.out", "w", stdout);
#endif


    cin >> n;

    while (n--) {
        int c, val;
        cin >> c >> val;
        if (c == 1) insert(val);
        else if (c == 2) remove(val);
        else cout << search(val) << endl;
    }

    return 0;
}