Pagini recente » Cod sursa (job #2023163) | Cod sursa (job #2284103) | Cod sursa (job #1620144) | Cod sursa (job #1736368) | Cod sursa (job #2894098)
#include <iostream>
#include <fstream>
#include <vector>
#define nrmare 20000000
using namespace std;
ifstream f("hashuri.in");
ofstream g("hashuri.out");
vector<int> hashuri[nrmare];
bool cautare(int x){
for(auto i = 0; i < hashuri[x%nrmare].size();i++) {
if (hashuri[x%nrmare][i] == x)
return 1;
}
return 0;
}
void stergere(int x) {
for (auto i = 0; i < hashuri[x % nrmare].size(); i++) {
if (hashuri[x%nrmare][i] == x) {
hashuri[x % nrmare].pop_back();
break;
}
}
}
void adaugare(int x) {
if (!cautare(x)) {
hashuri[x%nrmare].push_back(x);
}
}
int main() {
int i;
f>>i;
while(i>0){
int aux,x;
f>>aux>>x;
if(aux == 1){
adaugare(x);
}
if(aux == 2){
stergere(x);
}
if(aux == 3){
g<<cautare(x)<<'\n';
}
--i;
}
return 0;
}