Pagini recente » Cod sursa (job #2777357) | Cod sursa (job #1587429) | Cod sursa (job #821553) | Cod sursa (job #2862330) | Cod sursa (job #649039)
Cod sursa(job #649039)
#include<cstdio>
#include<vector>
#define SIZE 719671
using namespace std;
int n, indice;
vector <int> L[SIZE];
int Cauta(int x) {
for(int i = 0; i < (int) L[indice].size(); i++)
if(L[indice][i] == x) return i;
return L[indice].size();
}
void Insert(int x) { if(Cauta(x) == (int)L[indice].size()) L[indice].push_back(x); }
void Delete(int x) { int i = Cauta(x); if(i != (int)L[indice].size()) L[indice].erase(L[indice].begin() + i); }
int main() {
int i, op, x;
freopen("hashuri.in", "r", stdin), freopen("hashuri.out", "w", stdout);
scanf("%d", &n);
for(i = 1; i <= n; i++) {
scanf("%d %d", &op, &x);
indice = x % SIZE;
switch(op) {
case 1: Insert(x); break;
case 2: Delete(x); break;
case 3: printf("%d\n", Cauta(x) != (int)L[indice].size() ); break;
}
}
return 0;
}