Pagini recente » Cod sursa (job #382148) | Cod sursa (job #2241831) | Cod sursa (job #946614) | Cod sursa (job #1417029) | Cod sursa (job #642792)
Cod sursa(job #642792)
#include <iostream>
#include <fstream>
#include <list>
using namespace std;
ifstream in("hashuri.in");
ofstream out("hashuri.out");
const int MAXIM = 1000000;
list<long> h[MAXIM];
list<long>::iterator it;
void solve() {
int n;
in >> n;
int t;
long x;
while (n--) {
in >> t >> x;
int pos = x % MAXIM;
if (1 == t) {
h[pos].push_front(x);
} else if (2 == t) {
h[pos].remove(x);
} else if (3 == t) {
bool done = false;
int pos = x % MAXIM;
for (it = h[pos].begin(); it != h[pos].end(); ++it) {
if (*it == x) {
done = true;
out << 1 << endl;
break;
}
}
if (! done) {
out << 0 << endl;
}
}
}
}
int main() {
solve();
return 0;
}