Cod sursa(job #1643113)

Utilizator BogdacutuSeniuc Bogdan Bogdacutu Data 9 martie 2016 17:37:49
Problema Hashuri Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.61 kb
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>

using namespace std;

#define SIZE 666013

vector<int> v[SIZE];

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

	int n, x, y;
	fin >> n;

	for (int i = 0; i < n; i++) {
		fin >> x >> y;
		int list = y % SIZE;
		vector<int>::iterator it(find(v[list].begin(), v[list].end(), y));
		if (x == 1) {
			if (it == v[list].end())
				v[list].push_back(y);
		} else if (x == 2) {
			if (it != v[list].end())
				v[list].erase(it);
		} else {
			fout << (it != v[list].end()) << '\n';
		}
	}
}