Pagini recente » Atasamentele paginii Profil CristinelAndrei | Istoria paginii utilizator/vladiaconescu | Istoria paginii utilizator/gafton13andreea | Diferente pentru utilizator/eudanip intre reviziile 100 si 74 | Cod sursa (job #2004069)
#include <iostream>
#include <fstream>
#include <unordered_map>
#include <cmath>
#include <vector>
#define ll long long
#define pb push_back
using namespace std;
ifstream in("hashuri.in");
ofstream out("hashuri.out");
const int NMax = 1e4 + 5;
const int inf = 1e9 + 5;
const int mod = 1e5 + 7;
int M;
vector<int> h[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 n : h[idx]) {
if (n == val) {
return 1;
}
}
return 0;
}
void add(int val) {
h[idx].pb(val);
}
void rem(int val) {
for (int k=0;k < h[idx].size();++k) {
if (h[idx][k] != val) {
continue;
}
swap(h[idx][k],h[idx][h[idx].size()-1]);
h[idx].pop_back();
return;
}
}