Pagini recente » Cod sursa (job #2308024) | Cod sursa (job #1802282) | Cod sursa (job #2311099) | Cod sursa (job #2162819) | Cod sursa (job #2744668)
#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(long x){
//int poz = hash_func(x);
melodii[x%997].push_back(x);
}
int index(long 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(long x){
int poz = x%997;
for(int i=0;i<melodii[poz].size();i++){
if(melodii[poz][i] == x){
melodii[poz].erase(melodii[poz].begin() + 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;
}