Pagini recente » Cod sursa (job #803470) | Cod sursa (job #2051835) | Cod sursa (job #2746675) | Cod sursa (job #1180383) | Cod sursa (job #642797)
Cod sursa(job #642797)
#include <iostream>
#include <fstream>
#include <list>
using namespace std;
ifstream in("hashuri.in");
ofstream out("hashuri.out");
const int MAXIM = 1000000;
list<int> h[MAXIM];
list<int>::iterator find(int x) {
int pos = x % MAXIM;
for (list<int>::iterator it = h[pos].begin(); it != h[pos].end(); ++it) {
if (*it == x) {
return it;
}
}
return h[pos].end();
}
void solve() {
int n;
in >> n;
int t;
int x;
while (n--) {
in >> t >> x;
int pos = x % MAXIM;
if (1 == t) {
if (find(x) == h[pos].end()) {
h[pos].push_front(x);
}
} else if (2 == t) {
list<int>::iterator it = find(x);
if (it != h[pos].end()) {
h[pos].erase(it);
}
} else if (3 == t) {
out << (find(x) != h[pos].end()) << endl;
}
}
}
int main() {
solve();
return 0;
}