Pagini recente » Cod sursa (job #1689444) | Cod sursa (job #2876646) | Cod sursa (job #2480838) | Cod sursa (job #2195045) | Cod sursa (job #2192536)
#include <fstream>
#include <vector>
using namespace std;
#define size 666013
vector<int> map[size];
vector<int>::iterator find_val(int x) {
vector<int>::iterator it;
for(it = map[x % size].begin(); it != map[x % size].end(); it++) {
if (*it == x) {
return it;
}
}
return map[x % size].end();
}
void erase_val(int x) {
vector<int>::iterator it = find_val(x);
if (it != map[x % size].end()) {
map[x % size].erase(it);
}
}
int main() {
ifstream fin("hashuri.in");
ofstream fout("hashuri.out");
int n, t, x;
fin >> n;
for (int i = 0; i < n; ++i) {
fin >> t >> x;
vector<int>::iterator it;
switch (t) {
case 1: if (find_val(x) == map[x % size].end()) {
map[x % size].push_back(x);
}
continue;
case 2:
erase_val(x);
continue;
case 3:
it = find_val(x);
if (it != map[x % size].end()) {
fout << "1\n";
} else {
fout << "0\n";
}
continue;
}
}
fin.close();
fout.close();
return 0;
}