Cod sursa(job #1850318)

Utilizator andreiulianAndrei andreiulian Data 18 ianuarie 2017 15:23:54
Problema Hashuri Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 1.17 kb
#include <iostream> 
#include <fstream>
#include <cmath>
//#include <vector>
//#include <set>
#include <algorithm>
#include <unordered_map>
#include <cstring>
//#include <string>
//#include <queue>
 
#define mp make_pair
#define pb push_back
#define ff(i, x, n) for (int i = x; i <= n; ++i)
#define dd cout << 
#define nn << '\n'
#define ss << ' ' <<
#define prim 1299709
using namespace std;
char t[10000005], c[25];
vector<int> v[prim];
bool cauta(int nr) {
    int l = nr % prim;
    for (auto it = v[l].begin(); it!= v[l].end(); ++it) {
        if (*it == nr) {
            return 1;
        }
    }
    return 0;
}
void sterge(int nr) {
    int l = nr % prim;
    for (auto it = v[l].begin(); it!= v[l].end(); ++it) {
        if (*it == nr) {
            *it = 0;
            return;
        }
    }
}
int main(){
        //freopen("schi.in", "r", stdin);
        //freopen("schi.out", "w", stdout);
        ifstream in("hashuri.in");
        ofstream out("hashuri.out");
    int n, a, b;
    bool e;
    in >> n;
    while (n--) {
		in >> a >> b;
		e = cauta(b);
		if (a == 3) {
			out << e << '\n';
		}
		if (a == 1 && !e) {
			v[b % prim].pb(b);
		}
		if (a == 2 && e) {
			sterge(b);
		}
	}
}