Pagini recente » Cod sursa (job #351149) | Cod sursa (job #2223060) | Cod sursa (job #226356) | Cod sursa (job #562401) | Cod sursa (job #389259)
Cod sursa(job #389259)
#include <cstdio>
#include <vector>
using namespace std;
#define file_in "hashuri.in"
#define file_out "hashuri.out"
#define mod 666013
int T,x,tip;
vector<int> G[mod+10];
int cauta(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 baga(int x)
{
int k=x%mod;
if (cauta(x))
return ;
G[k].push_back(x);
}
void sterge(int x)
{
if (!cauta(x))
return ;
vector<int> :: iterator it;
int k=x%mod;
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);
scanf("%d", &T);
while(T--)
{
scanf("%d %d", &tip, &x);
if (tip==1)
baga(x);
else
if (tip==2)
sterge(x);
else
printf("%d\n", cauta(x));
}
fclose(stdin);
fclose(stdout);
return 0;
}