Pagini recente » Cod sursa (job #2623868) | Cod sursa (job #1290671) | Cod sursa (job #2624466) | Cod sursa (job #1599353) | Cod sursa (job #1991700)
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
ifstream in("hashuri.in");
ofstream out("hashuri.out");
#define ll long long
#define pb push_back
const int inf = 1e9 + 5;
const int NMax = 15;
const int mod = 100005;
int M;
vector<int> h[mod];
bool have(int);
void rem(int);
void add(int);
int main() {
in>>M;
while (M--) {
int tip,x;
in>>tip>>x;
switch(tip) {
case 1: {
if (!have(x)) {
add(x);
}
break;
}
case 2: {
rem(x);
break;
}
default: {
if (have(x)) {
out<<"1\n";
}
else {
out<<"0\n";
}
}
}
}
in.close();out.close();
return 0;
}
#define idx val % mod
bool have(int val) {
for (int elem : h[idx]) {
if (elem == val) {
return true;
}
}
return false;
}
void rem(int val) {
int dim = h[idx].size();
for (int k=0;k < dim;++k) {
if (h[idx][k] != val) {
continue;
}
swap(h[idx][k],h[idx][dim-1]);
h[idx].pop_back();
return;
}
}
void add(int val) {
h[idx].pb(val);
}