Pagini recente » Cod sursa (job #2096714) | Cod sursa (job #2038078) | Cod sursa (job #437759) | Cod sursa (job #845121) | Cod sursa (job #3001690)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("hashuri.in");
ofstream fout("hashuri.out");
const int P = 123457;
vector<int>h[123457];
int n;
int Find(int x){
int p = x % P;
for(int i = 0; i < h[p].size(); i++)
if(h[p][i] == x)
return 1;
return 0;
}
void Add(int x){
int p = x % P;
if(!Find(x))
h[p].push_back(x);
}
void Remove(int x){
int p = x % P;
if(Find(x)){
int r = h[p].size();
for(int i = 0; i < r; i++)
if(h[p][i] == x){
h[p][i] = h[p][r-1];
break;
}
h[p].pop_back();
}
}
int main()
{
int x, y, task;
fin >> n ;
for(int i = 1; i <= n; i++){
fin >> task >> x;
if(task == 1)
Add(x);
else if(task == 2)
Remove(x);
else
fout << Find(x) << "\n";
}
return 0;
}