Pagini recente » Cod sursa (job #2283775) | Cod sursa (job #1005004) | Cod sursa (job #1750839) | Cod sursa (job #3244725) | Cod sursa (job #2889992)
#include <iostream>
#include <fstream>
#include<vector>
using namespace std;
#define MOD 666013
vector<int> hashh[MOD];
vector<int>::iterator gasesteVal(int x) {
int y = x % MOD;
vector<int>::iterator it;
for (it = hashh[y].begin(); it != hashh[y].end(); it++) {
if (*it == x)
return it;
}
return hashh[y].end();
}
void adaugaVal(int x) {
int y = x % MOD;
if (gasesteVal(x) == hashh[y].end())
hashh[y].push_back(x);
}
void stergeVal(int x) {
int y = x % MOD;
if (gasesteVal(x) != hashh[y].end())
hashh[y].erase(gasesteVal(x));
}
void afis(){
for(auto it:hashh[MOD])
cout<<it<<" ";
}
int main() {
long long N;
ifstream f("hashuri.in");
ofstream g("hashuri.out");
f >> N;
long long x, y;
hashh[10].push_back(10);
for (int i = 0; i < N; i++) {
f >> x >> y;
if (x == 1) {
adaugaVal(y);
continue;
}
if (x == 2) {
stergeVal(y);
continue;
}
g << (gasesteVal(y) != hashh[ y % MOD].end()) << "\n";
}
}