Pagini recente » Cod sursa (job #2160295) | Cod sursa (job #2624568) | Cod sursa (job #2445886) | Cod sursa (job #2733206) | Cod sursa (job #2622431)
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
const int mod = 66666;
vector<int> hasht[mod];
ifstream f("hashuri.in");
ofstream g("hashuri.out");
void add(int x){
int m = x % mod;
hasht[m].push_back(x);
}
void deleteh(int x){
int m = x % mod;
for (int i = 0; i < hasht[m].size(); i++){
if(hasht[m][i] == x){
hasht[m].erase(hasht[m].begin()+i);
return;
}
}
}
int searchh(int x){
int m = x % mod;
for (int i = 0; i < hasht[m].size(); i++){
if(hasht[m][i] == x){
return 1;
}
}
return 0;
}
int main()
{
int n, x, y;
f>>n;
for(int i = 0; i < n; i++){
f >> x >> y;
if(x == 1)
add(y);
if(x == 2)
deleteh(y);
if(x == 3)
g << searchh(y) << endl;
}
return 0;
}