Pagini recente » Cod sursa (job #2387297) | Cod sursa (job #825274) | Cod sursa (job #41277) | Cod sursa (job #496607) | Cod sursa (job #487336)
Cod sursa(job #487336)
#include <stdio.h>
#include <math.h>
#include <vector>
#define PRIME 601589
using namespace std;
vector <long> has[PRIME];
long i, n, poz, choice, num, s, j;
int main() {
freopen("hashuri.in", "r", stdin);
freopen("hashuri.out", "w", stdout);
scanf("%ld", &n);
for (i = 1; i <= n; ++i) {
poz = -1;
scanf("%ld %ld", &choice, &num);
long pri = num % PRIME;
s = has[pri].size();
for (j = 0; j < s; ++j) {
if (has[pri][j] == num) {
poz = j;
break;
}
}
if (choice == 3) {
if (poz >= 0)
printf("1\n");
else
printf("0\n");
continue;
}
if (choice == 1) {
has[pri].push_back(num);
}
if (choice == 2) {
if (poz >= 0) {
has[pri].erase(has[pri].begin() + poz, has[pri].begin() + poz + 1);
}
}
}
return 0;
}