Pagini recente » Cod sursa (job #1134826) | Cod sursa (job #847151) | Cod sursa (job #1918848) | Cod sursa (job #1898030) | Cod sursa (job #1875216)
#include <iostream>
#include <fstream>
#include <cstring>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <list>
#define MOD 66601
using namespace std;
class sett{
private:
list<int> modLists[MOD];
public:
sett(){
}
void add(int x){
int pos = x % MOD;
//cout << pos << endl;
modLists[pos].push_back(x);
}
bool contains(int x){
int pos = x % MOD;
for (list<int>::iterator it = modLists[pos].begin(); it != modLists[pos].end(); ++it)
if (*it == x){
return true;
}
return false;
}
void remove(int x){
int pos = x % MOD;
modLists[pos].remove(x);
}
};
ifstream f("hashuri.in");
ofstream g("hashuri.out");
int main(){
int n;
f >> n;
sett s;
for(int i = 0; i < n; i++){
int option, value;
f >> option >> value;
switch(option){
case 1:
s.add(value);
break;
case 2:
s.remove(value);
break;
case 3:
g << s.contains(value) << endl;
break;
default:
cout << "f you :)" << endl;
}
}
return 0;
}