Pagini recente » Cod sursa (job #966213) | Cod sursa (job #2558002) | Cod sursa (job #2141801) | Borderou de evaluare (job #1973670) | Cod sursa (job #609805)
Cod sursa(job #609805)
#include <fstream>
#include <vector>
using namespace std;
const int mod=666013;
vector<int> a[mod];
ifstream in("hashuri.in");
ofstream out("hashuri.out");
vector<int>::iterator find(int x)
{
int L=x%mod;
for (vector<int>::iterator i=a[L].begin();i!=a[L].end();i++)
if (*i==x)
return i;
return a[L].end();
}
void push(int x)
{
int L=x%mod;
if (find(x)==a[L].end())
a[L].push_back(x);
}
void pop(int x)
{
int L=x%mod;
vector<int>::iterator i=find(x);
if (i!=a[L].end())
a[L].erase(i);
}
int main()
{
int n,q,x;
in>>n;
while (n--)
{
in>>q>>x;
if (q==1)
push(x);
if (q==2)
pop(x);
if (q==3)
out<<(find(x)!=a[x%mod].end())<<"\n";
}
return 0;
}