Cod sursa(job #2681720)

Utilizator TheGodFather2131Alexandru Miclea TheGodFather2131 Data 6 decembrie 2020 14:45:46
Problema Hashuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 1.19 kb
//ALEXANDRU MICLEA

#include <vector>
#include <algorithm>
#include <string>
#include <string.h>
#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 <assert.h>

using namespace std;
using ll = long long;

#include <fstream>
//ifstream cin("input.in"); ofstream cout("output.out");
ifstream cin("hashuri.in"); ofstream cout("hashuri.out");


//VARIABLES

const int MOD = 666013;
vector <int> v[MOD + 2];

//FUNCTIONS

void add(int val) {
	v[val % MOD].push_back({ val / MOD });
}

void remove(int val) {
	vector <int> aux;

	for (auto& x : v[val % MOD]) {
		if (x != val / MOD) aux.push_back(x);
	}

	v[val % MOD] = aux;
}

int Query(int val) {
	for (auto& x : v[val % MOD]) {
		if (x == val / MOD) return 1;
	}

	return 0;
}

//MAIN

int main() {

	int q; cin >> q;

	while (q--) {
		int c, n; cin >> c >> n;

		if (c == 1) add(n);
		if (c == 2) remove(n);
		if (c == 3) cout << Query(n) << '\n';
	}

	return 0;
}