Pagini recente » Istoria paginii runda/testsimulareoni_cls_11-12 | Cod sursa (job #1233945) | Cod sursa (job #711314) | Diferente pentru calibrare-limite-de-timp intre reviziile 217 si 221 | Cod sursa (job #1991540)
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <stack>
#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 = 2e6 + 5;
const int mod = 100001;
int N,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: {
if (have(x)) {
out<<1<<'\n';
}
else {
out<<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 i=0;i < v[idx].size();++i) {
if (v[idx][i] != val) {
continue;
}
swap(v[idx][i],v[idx][v[idx].size()-1]);
v[idx].pop_back();
return;
}
}