Pagini recente » Cod sursa (job #59416) | Cod sursa (job #2175078) | Cod sursa (job #149438) | Cod sursa (job #747318) | Cod sursa (job #2894803)
#include <iostream>
#include <fstream>
#include <vector>
#define val 668821
using namespace std;
ifstream fin("hashuri.in");
ofstream fout("hashuri.out");
vector <int> M[val];
vector <int> :: iterator check (int x){
int l = x % val;
vector <int> :: iterator pos;
for (pos = M[l].begin(); pos != M[l].end(); pos++)
if(*pos == x)
return pos;
return M[l].end();
}
void insert (int x){
int l = x % val;
if (check(x) == M[l].end())
M[l].push_back(x);
}
void clear (int x) {
int l = x % val;
vector<int>::iterator pos;
pos = check(x);
if (pos != M[l].end())
M[l].erase(pos);
}
int main() {
int N, operatie, parametru;
fin >> N;
for (int i=0; i<N; i++){
fin >> operatie >> parametru;
if (operatie == 1)
insert(parametru);
else if (operatie == 2)
clear(parametru);
else if (operatie == 3){
if (check(parametru) == M[parametru % val].end())
fout << 0;
else fout << 1;
}
}
return 0;
}