Pagini recente » Cod sursa (job #253097) | Cod sursa (job #2376512) | Cod sursa (job #2606305) | Cod sursa (job #3001067) | Cod sursa (job #1402715)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("hashuri.in");
ofstream fout("hashuri.out");
const int MOD = 999983;
vector <int> hash1[MOD];
vector <int>:: iterator it;
int x, op, n;
bool gas(int x, int poz)
{
for(it = hash1[poz].begin(); it != hash1[poz].end(); it++)
if (*it == x) return true;
return false;
}
void o1(int x)
{
int mod = x % MOD;
if (!gas(x, x % MOD))
hash1[mod].push_back(x);
}
void o2(int x)
{
int mod = x % MOD;
for (it = hash1[mod].begin(); it != hash1[mod].end(); it++)
if (*it == x)
{
*it = hash1[mod].back();
hash1[mod].pop_back();
return;
}
}
void o3(int x)
{
if (gas(x, x % MOD)) fout << "1";
else fout << "0";
fout << "\n";
}
int main()
{
fin >> n;
for (; n; n--)
{
fin >> op >> x;
if (op == 1) {o1(x); continue;}
else if (op == 2) {o2(x); continue;}
o3(x);
}
}