Pagini recente » Cod sursa (job #19336) | Cod sursa (job #971727) | Cod sursa (job #842697) | Cod sursa (job #2405161) | Cod sursa (job #2744665)
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
ifstream f("hashuri.in");
ofstream g("hashuri.out");
int n,operatie;
long x;
vector<long> melodii[1000];
/*
int hash_func(int x){
return x%97;
}
*/
void push(int x){
//int poz = hash_func(x);
melodii[x%997].push_back(x);
}
int index(int x){
int poz = x%997;
for(int i=0;i<melodii[poz].size();i++){
if(melodii[poz][i] == x){
melodii[poz][i] = 0;
return 1;
}
}
return 0;
}
void pop(int x){
int poz = x%997;
for(int i=0;i<melodii[poz].size();i++){
if(melodii[poz][i] == x){
melodii[poz].erase(i);
}
}
}
int main(){
f>>n;
for(int i=0;i<n;i++){
f>>operatie>>x;
if(operatie == 1) push(x);
if(operatie == 2) pop(x);
if(operatie == 3) g<<index(x)<<'\n';
}
return 0;
}