Pagini recente » Cod sursa (job #1581409) | Cod sursa (job #1618485) | Cod sursa (job #1938969) | Cod sursa (job #2816451) | Cod sursa (job #2744921)
#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%113;
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%113].push_back(x);
}
}
void pop(int x){
int poz = x%113;
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;
}