Pagini recente » Cod sursa (job #2344117) | Cod sursa (job #70858) | Cod sursa (job #813995) | Cod sursa (job #1794495) | Cod sursa (job #524255)
Cod sursa(job #524255)
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
#define file_in "hashuri.in"
#define file_out "hashuri.out"
#define mod 666013
int Q,tip,x;
vector<int> G[1010010];
#define dim 8192
char ax[dim];
int pz;
inline void cit (int &x)
{
x = 0;
while (ax[pz] < '0' || ax[pz] > '9')
if (++pz == dim)
fread (ax, 1, dim, stdin), pz = 0;
while (ax[pz] >= '0' && ax[pz] <= '9')
{
x = x * 10 + ax[pz] - '0';
if (++pz == dim)
fread (ax, 1, dim, stdin), pz = 0;
}
}
void add(int x){
int k=x%mod;
G[k].push_back(x);
}
int find(int x){
int k=x%mod;
vector<int> :: iterator it;
for (it=G[k].begin();it!=G[k].end();++it)
if (*it==x)
return 1;
return 0;
}
void erase(int x){
int k=x%mod;
if (!find(x))
return ;
vector<int> :: iterator it;
for (it=G[k].begin();it!=G[k].end();++it)
if (*it==x){
G[k].erase(it);
return ;
}
}
int main(){
freopen(file_in,"r",stdin);
freopen(file_out,"w",stdout);
cit(Q);
while(Q--){
cit(tip);
cit(x);
if (tip==1){
add(x);
}
else
if (tip==2){
erase(x);
}
else{
printf("%d\n", find(x));
}
}
return 0;
}