Pagini recente » Cod sursa (job #3205348) | Cod sursa (job #1599138) | Cod sursa (job #884141) | Cod sursa (job #1974680) | Cod sursa (job #1648325)
#include <fstream>
#include <vector>
#define Mod 666013
using namespace std;
ifstream cin("hashuri.in");
ofstream cout("hashuri.out");
vector < int > Hash[Mod];
int n;
void insert(int x){
int ok = 0;
for(vector < int > :: iterator it = Hash[x % Mod].begin(); it != Hash[x % Mod].end() && ok == 0; ++it)
if(*it == x)
ok = 1;
if(ok == 0)
Hash[x % Mod].push_back(x);
}
void erase(int x){
int ok = 0;
for(vector < int > :: iterator it = Hash[x % Mod].begin(); it != Hash[x % Mod].end() && ok == 0; ++it)
if(*it == x){
ok = 1;
*it = -1;
}
}
int find(int x){
int ok = 0;
for(vector < int > :: iterator it = Hash[x % Mod].begin(); it != Hash[x % Mod].end() && ok == 0; ++it)
if(*it == x)
ok = 1;
return ok;
}
int main(){
cin >> n;
for(int i = 1; i <= n; ++i){
int Type, x;
cin >> Type >> x;
if(Type == 1)
insert(x);
if(Type == 2)
erase(x);
if(Type == 3)
cout << find(x) << "\n";
}
return 0;
}