Pagini recente » Cod sursa (job #2286299) | Cod sursa (job #3321074) | Cod sursa (job #3301627) | Cod sursa (job #2580368) | Cod sursa (job #3328685)
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
ifstream fin("hashuri.in");
ofstream fout("hashuri.out");
int n, op, x, ok;
const int MOD = 666013;
vector<int> H[MOD];
int main()
{
fin >> n;
for (int i = 1; i <= n; i++)
{
fin >> op >> x;
// cout << op << " " << x << "\n";
ok = 0;
if (op == 1)
{
// cout << op << " " << x << "\n";
for (int j = 0; j < H[x % MOD].size(); j++)
{
// cout << 'a' << "\n";
if (H[x % MOD][j] == x)
{
// cout << 'a' << "\n";
ok = 1;
break;
}
}
if (ok == 0)
H[x % MOD].push_back(x);
}
// cout << 'a' << "\n";
if (op == 2)
{
// cout << op << " " << x << "\n";
for (int j = 0; j < H[x % MOD].size(); j++)
if (H[x % MOD][j] == x)
{
while (j + 1 < H[x % MOD].size())
{
H[x % MOD][j] = H[x % MOD][j + 1];
}
H[x % MOD].pop_back();
break;
}
}
if (op == 3)
{
// cout << op << " " << x << "\n";
for (int j = 0; j < H[x % MOD].size(); j++)
if (H[x % MOD][j] == x)
{
fout << 1 << " \n";
ok = 1;
break;
}
if (ok == 0)
fout << 0 << "\n";
}
}
return 0;
}