Pagini recente » Cod sursa (job #1653999) | Cod sursa (job #1319626) | Cod sursa (job #1903212) | Cod sursa (job #2232741) | Cod sursa (job #1503420)
#include <fstream>
#include <vector>
using namespace std;
const int NMAX = 1000001;
const int M = 666013;
int N;
vector<int> h[M];
void adauga(int x) {
h[x % M].push_back(x);
}
void sterge(int x) {
int value = x % M;
for(unsigned i = 0 ; i < h[value].size(); ++i)
if(h[value][i] == x) {
swap(h[value][i], h[value][ h[value].size() - 1]);
h[value].pop_back();
break;
}
}
int interogare(int x) {
int value = x % M;
for(unsigned i = 0 ; i < h[value].size() ; ++i)
if(h[value][i] == x)
return 1;
return 0;
}
int main() {
ifstream fin ("hashuri.in");
ofstream fout ("hashuri.out");
fin >> N;
while(N--) {
int type; int x;
fin >> type >> x;
switch(type) {
case 1: adauga(x); break;
case 2: sterge(x); break;
case 3: fout << interogare(x) << '\n'; break;
}
}
return 0;
}