Pagini recente » Cod sursa (job #2126149) | Cod sursa (job #332536) | Cod sursa (job #1635561) | Cod sursa (job #1722868) | Cod sursa (job #642796)
Cod sursa(job #642796)
#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 it;
bool find(int x) {
int pos = x % MAXIM;
for (it = h[pos].begin(); it != h[pos].end(); ++it) {
if (*it == x) {
return true;
}
}
return false;
}
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].push_front(x);
}
} else if (2 == t) {
h[pos].remove(x);
} else if (3 == t) {
out << find(x) << endl;
}
}
}
int main() {
solve();
return 0;
}