Pagini recente » Cod sursa (job #2703543) | Cod sursa (job #983846) | Cod sursa (job #2657925) | Cod sursa (job #3240615) | Cod sursa (job #1603354)
#include <fstream>
#include <algorithm>
#include <vector>
using namespace std;
ifstream fin("hashuri.in");
ofstream fout("hashuri.out");
const int MOD = 579107;
vector<int> h[MOD];
inline void Insert(const int x) {
const int line = x % MOD;
for (unsigned int i = 0; i < h[line].size(); ++i) {
if (h[line][i] == x) {
return;
}
}
h[line].push_back(x);
}
inline void Delete(const int x) {
const int line = x % MOD;
for (unsigned int i = 0; i < h[line].size(); ++i) {
if (h[line][i] == x) {
swap(h[line][i], h[line][h[line].size() - 1]);
h[line].pop_back();
}
}
}
inline bool Check(const int x) {
const int line = x % MOD;
for (unsigned int i = 0; i < h[line].size(); ++i) {
if (h[line][i] == x) {
return 1;
}
}
return 0;
}
int n;
int main() {
fin >> n;
for (int i = 1;i <= n; ++i) {
int a, b;
fin >> a >> b;
if (a == 1) {
Insert(b);
}
else if (a == 2) {
Delete(b);
}
else {
fout << Check(b) << '\n';
}
}
fout.close();
return 0;
}