Pagini recente » Cod sursa (job #940086) | Cod sursa (job #942243) | Cod sursa (job #1143026) | Cod sursa (job #2431362) | Cod sursa (job #1993481)
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <vector>
using namespace std;
ifstream in("hashuri.in");
ofstream out("hashuri.out");
#define ll long long
#define pb push_back
#define ui unsigned int
const int inf = 1e9 + 5;
const int NMax = 1e5 + 5;
const int mod = 100005;
int M;
vector<int> v[mod];
bool have(int);
void add(int);
void rem(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;
}
case 3: {
out<<( have(x) ? 1 : 0)<<'\n';
break;
}
}
}
in.close();out.close();
return 0;
}
#define idx val % mod
bool have(int val) {
for (int elem : v[idx]) {
if (elem == val) {
return true;
}
}
return false;
}
void add(int val) {
v[idx].pb(val);
}
void rem(int val) {
for (int k=0;k < (int)v[idx].size();++k) {
if (v[idx][k] != val) {
continue;
}
swap(v[idx][k],v[idx][v[idx].size()-1]);
v[idx].pop_back();
return;
}
}