Cod sursa(job #2400660)

Utilizator The_one_and_onlyMironica Vasile The_one_and_only Data 8 aprilie 2019 23:20:38
Problema Hashuri Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.79 kb
#include <fstream>
#include <vector>
#define mod 576101
typedef unsigned long long ll;
using namespace std;

ifstream cin("hashuri.in");
ofstream cout("hashuri.out");

vector<ll> a[mod];
int n;

int find(ll h) {
	int m = h % mod, i = 0;
	while(i < a[m].size() && a[m][i] != h)
		i++;
	return i;
}

void push(ll h) {
	int m = h % mod;
	if(find(h) == a[h % mod].size())
		a[h % mod].push_back(h);
}

void pop(ll h) {
	int it = find(h), m = h % mod;
	if(it != a[m].size())
		a[m].erase(a[m].begin() + it);
}

int main() {
	cin >> n;
	while(n--) {
		ll h;
		int cer;
		cin >> cer >> h;
		switch(cer) {
			case 1:
				push(h);
				break;
			case 2:
				pop(h);
				break;
			case 3:
				cout << (find(h) != a[h % mod].size()) << '\n';
				break;
		}
	}
	return 0;
}