Pagini recente » Cod sursa (job #436603) | Cod sursa (job #599611) | Cod sursa (job #927117) | Cod sursa (job #2649098) | Cod sursa (job #2747260)
#include <iostream>
#include <fstream>
#include <bits/stdc++.h>
using namespace std;
ifstream in("hashuri.in");
ofstream out("hashuri.out");
#define M 666013
vector<int> v[M];
int n,operatie,x;
void adauga(int x){
int list=x%M;
int ok=0;
for(unsigned int i=0; i<v[list].size(); i++)
if(v[list][i]==x) ok=1;
if(ok==0)
v[list].push_back(x);
else
return;
}
void sterge(int x){
int list=x%M;
for(unsigned int i=0; i<v[list].size(); i++){
if(v[list][i]==x){
v[list].erase(v[list].begin() + i);
break;
}
}
}
int cauta(int x){
int list=x%M;
for(unsigned int i=0; i<v[list].size(); i++)
if(v[list][i]==x) return 1;
return 0;
}
int main(){
in>>n;
int ok;
for(int i=0; i<n; i++){
in>>operatie>>x;
if(operatie==1){
adauga(x);
}
if(operatie==2){
sterge(x);
}
if(operatie==3){
ok=cauta(x);
out<<ok<<'\n';
}
}
in.close();
out.close();
}