Pagini recente » Cod sursa (job #2289127) | Cod sursa (job #281111) | Cod sursa (job #1697305) | Cod sursa (job #2397223) | Cod sursa (job #2698424)
#include <iostream>
#include <fstream>
#include <vector>
#define MOD 666013
using namespace std;
ifstream fin ("hashuri.in");
ofstream fout ("hashuri.out");
vector <int> G[MOD];
inline vector<int>::iterator find_value(int x)
{
int list=x%MOD;
for (auto it=G[list].begin(); it!=G[list].end(); it++)
{
if (*it==x)
return it;
}
return G[list].end();
}
int main()
{
int n;
fin>>n;
for (int i=1; i<=n; i++) {
int tip, x;
fin>>tip>>x;
if (tip==1) {
int list=x%MOD;
if (find_value(x)==G[list].end())
G[list].push_back(x);
}
if (tip==2) {
int list=x%MOD;
auto it=find_value(x);
if (it!=G[list].end())
G[list].erase(it);
}
if (tip==3) {
int list=x%MOD;
if (find_value(x)!=G[list].end()) fout<<1<<'\n';
else fout<<0<<'\n';
}
}
return 0;
}