Pagini recente » Cod sursa (job #2696405) | Cod sursa (job #1902262) | Cod sursa (job #2552835) | Cod sursa (job #2529301) | Cod sursa (job #2896292)
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
ifstream fin("hashuri.in");
ofstream fout("hashuri.out");
vector <int> hash1[666018];
int main()
{ int i, k, n, j, x, op, r, gasit, poz,aux;
k = 666013;
fin>>n;
for(i = 1; i <= n; i++){
fin>>op>>x;
gasit = 0;
r = x % k;
for(j = 0; j < hash1[r].size(); j++){
if(hash1[r][j] == x){
gasit = 1;
poz = j;
break;
}
}
if(op == 1){
if(gasit == 0)
hash1[r].push_back(x);
}
else{
if(op == 2){
if(gasit == 1){
swap(hash1[r][j],hash1[r].back());
hash1[r].pop_back();
}
}
else{
if(gasit == 1)
fout<<1<<'\n';
else
fout<<0<<'\n';
}
}
}
return 0;
}