Pagini recente » Cod sursa (job #2865396) | Cod sursa (job #3317879) | Cod sursa (job #1098538) | Cod sursa (job #1962043) | Cod sursa (job #3343136)
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;
ifstream fin("hashuri.in");
ofstream fout("hashuri.out");
const int mod=666013;
vector<int> v[mod];
int n,op,x;
inline int cautare(int x)
{
int rest=x%mod;
for (int i=0;i<(int) v[rest].size();i++)
if (v[rest][i]==x)
return i+1;
return 0;
}
inline void add(int x)
{
int rest=x%mod;
if (cautare(x)==0)
v[rest].push_back(x);
}
inline void stergere(int x)
{
int rest=x%mod;
for (auto it=v[rest].begin();it!=v[rest].end();it++)
if (*it==x)
{
v[rest].erase(it);
break;
}
}
int main()
{
ios::sync_with_stdio(false);
fin.tie(0);
fout.tie(0);
fin>>n;
while (n--)
{
fin>>op>>x;
if (op==1)
add(x);
if (op==2)
stergere(x);
if (op==3)
fout<<(cautare(x)!=0)<<"\n";
}
return 0;
}