Pagini recente » Cod sursa (job #1835620) | Cod sursa (job #2963513) | Cod sursa (job #1841498) | Cod sursa (job #731774) | Cod sursa (job #994220)
Cod sursa(job #994220)
#include <fstream>
#include <vector>
using namespace std;
ifstream f("hashuri.in");
ofstream g("hashuri.out");
const int M=660013;
vector<int> mp[M];
typedef vector<int>::iterator it;
inline int h(int x){
return x%M;
}
inline it search(int x){
int y=h(x);
for(it i=mp[y].begin();i!=mp[y].end();i++)
if(*i==x)
return i;
return mp[y].end();
}
void add(int x){
int y=h(x);
if(search(x) != mp[y].end()) return;
mp[y].push_back(x);
return;
}
void erase(int x){
it ax=search(x);
if(ax==mp[h(x)].end()) return;
mp[h(x)].erase(ax);
return;
}
int main()
{
int n;
f>>n;
for(int i=1;i<=n;i++){
int op,x;
f>>op>>x;
switch(op){
case 1:add(x); break;
case 2:erase(x); break;
case 3:g<<( search(x) != mp[h(x)].end() )<<'\n'; break;
}
}
return 0;
}