Pagini recente » Cod sursa (job #615696) | Cod sursa (job #2242554) | Cod sursa (job #866214) | Cod sursa (job #1904357) | Cod sursa (job #1653332)
#include <fstream>
#include <set>
using namespace std;
static const int MOD = 666013;
set<int> Table[MOD];
set<int>::iterator operation_search(int x)
{
int index = x % MOD;
set<int>::iterator it;
for(it = Table[index].begin(); it != Table[index].end(); ++it)
if (*it == x)
return it;
return Table[index].end();
}
void operation_add(int x)
{
int index = x % MOD;
Table[index].insert(x);
}
void operation_remove(int x)
{
int index = x % MOD;
Table[index].erase(x);
}
int main()
{
int N,x,op;
fstream f("hashuri.in",ios::in);
ofstream g("hashuri.out");
f>>N;
do
{
f>>op>>x;
if(op==1)operation_add(x);
else if(op==2)operation_remove(x);
else
{
int index = x % MOD;
if(operation_search(x)!=Table[index].end())
g<<'1'<<'\n';
else g<<'0'<<'\n';
}
}while(--N);
return 0;
}