Pagini recente » Cod sursa (job #2556555) | Cod sursa (job #3190812) | Cod sursa (job #424228) | Cod sursa (job #2879722) | Cod sursa (job #1650188)
# include <fstream>
# include <vector>
# define foreach(A) for(typeof (A).begin() it = (A).begin(); it != (A).end(); ++it)
using namespace std;
ifstream fin("hashuri.in");
ofstream fout("hashuri.out");
const int MOD = 666013;
vector<int> h[MOD];
bool Verifica(int x) {
int key = x % MOD;
foreach(h[key])
if (*it == x)
return 1;
return 0;
}
void Adauga(int x) {
if (!Verifica(x)) {
int key = x % MOD;
h[key].push_back(x);
}
}
void Sterge(int x) {
int key = x % MOD;
foreach (h[key])
if (*it == x) {
h[key].erase(it);
break;
}
}
int N, t, x;
int main() {
fin >> N;
while (N--) {
fin >> t >> x;
if (t == 1) Adauga(x);
if (t == 2) Sterge(x);
if (t == 3) fout << Verifica(x) << "\n";
}
return 0;
}