Pagini recente » Cod sursa (job #1676733) | Cod sursa (job #2351449) | Cod sursa (job #1445025) | Cod sursa (job #2294727) | Cod sursa (job #256327)
Cod sursa(job #256327)
#include<cstdio>
#include<vector>
using namespace std;
#define INPUT "hashuri.in"
#define OUTPUT "hashuri.out"
#define MOD 666013
FILE *fin = fopen(INPUT, "r"), *fout = fopen(OUTPUT, "w");
vector<long> Vec[ MOD + 1];
void insert(long Value)
{
long pozNod = Value % MOD;
Vec[ pozNod ].push_back(Value);
}
void extract(long Value)
{
vector<long>::iterator it;
long pozNod = Value % MOD;
for(it = Vec[ pozNod ].begin(); it != Vec[ pozNod ].end(); ++it)
{
if(*it == Value)
Vec[ pozNod ].erase(it);
return;
}
}
int verify(long Value)
{
vector<long>::iterator it;
long pozNod = Value % MOD;
for(it = Vec[ pozNod ].begin(); it != Vec[ pozNod ].end(); ++it)
{
if(*it == Value)
return 1;
}
return 0;
}
int main()
{
long N, Code, Value;
fscanf(fin, "%ld", &N);
for(long i = 0; i < N; ++i)
{
fscanf(fin, "%ld %ld", &Code, &Value);
if(Code == 1)
{
if(!verify(Value)) insert(Value);
}
else
if(Code == 2)
{
if(verify(Value)) extract(Value);
}
else
if(Code == 3)
fprintf(fout, "%d\n", verify(Value));
}
fclose(fin);
fclose(fout);
return 0;
}