Pagini recente » Istoria paginii runda/oni_11_12_8/clasament | Cod sursa (job #2453957) | Istoria paginii runda/ichc_preoji2010/clasament | Cod sursa (job #804785) | Cod sursa (job #2744918)
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
ifstream f("hashuri.in");
ofstream g("hashuri.out");
vector<int> h[1000];
bool index(int x){
int poz = x%89;
for(int i=0;i<h[poz].size();i++){
if(h[poz][i] == x) return true;
}
return false;
}
void push(int x){
if(!index(x)){
h[x%89].push_back(x);
}
}
void pop(int x){
int poz = x%89;
for(int i=0;i<h[poz].size();i++){
if(h[poz][i]==x){
h[poz].erase(h[poz].begin()+i);
return;
}
}
}
int main(){
int n, operatie, x;
f>>n;
for(int i=0;i<n;i++){
f>>operatie>>x;
if(operatie == 1) push(x);
else{
if(operatie == 2) pop(x);
else g<<index(x)<<'\n';
}
}
return 0;
}