Cod sursa(job #2761799)

Utilizator cosmin1812Nedelcu Adrian Cosmin cosmin1812 Data 4 iulie 2021 02:11:37
Problema Hashuri Scor 60
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.82 kb
#include<iostream>
#include<fstream>
#include<vector>
using namespace std;

ifstream f("hashuri.in");
ofstream g("hashuri.out");


int main()
{

	long long prim = 666013;

	vector< vector<long long> >hash(prim);
	int n;
	f >> n;
	long long op, x;
	long long cod;


	for (int i = 0; i < n; i++) {

		f >> op >> x;
		cod = x % prim;

		if (op == 1) {

			hash[cod].push_back(x);

		}

		if (op == 2) {

			for (int j = 0; j < hash[cod].size(); j++) {

				if (hash[cod][j] == x)
					hash[cod].erase(hash[cod].begin() + j);

			}

		}

		if (op == 3) {

			int ok = 0;

			for (int j = 0; j < hash[cod].size(); j++) {
			
				if (hash[cod][j] == x) {

					ok = 1;
					g << ok << endl;
					break;
				}
			
			}

			if (ok == 0) {

				g << ok << endl;
			}

		}


	}

}