Pagini recente » Cod sursa (job #1450859) | Cod sursa (job #1829419) | Cod sursa (job #1144727) | Cod sursa (job #462159) | Cod sursa (job #527616)
Cod sursa(job #527616)
#include <fstream>
#include <vector>
#define MOD 666013
using namespace std;
vector <int> v[MOD + 3];
int dim[MOD + 3];
int search(long long x)
{
for(int i = 0; i < dim[x % MOD]; ++i)
if(v[x % MOD][i] == x)
return (i + 1);
return 0;
}
void del(long long x)
{
if(search(x))
v[x % MOD][search(x) - 1] = -1;
}
void add(long long x)
{
if(!search(x))
{
v[x % MOD].push_back(x);
++dim[x % MOD];
}
}
int main()
{
ifstream f("hashuri.in");
ofstream g("hashuri.out");
int n;
f >> n;
for(int i = 1; i <= n; ++i)
{
long long x;
short type;
f >> type >> x;
if(type == 1)
add(x);
if(type == 2)
del(x);
if(type == 3)
if(search(x))
g << "1\n";
else
g << "0\n";
}
f.close();
g.close();
return 0;
}