Pagini recente » Cod sursa (job #738102) | Cod sursa (job #2965712) | Cod sursa (job #2377667) | Cod sursa (job #1619090) | Cod sursa (job #1653222)
#include <fstream>
#include <vector>
using namespace std;
static const int MOD = 666013;
vector<int> Table[MOD];
//vector<int> G[MOD];
vector<int>::iterator operation_search(int x)
{
int index = x % MOD;
vector<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;
if(operation_search(x)==Table[index].end())
Table[index].push_back(x);
}
void operation_remove(int x)
{
int index = x % MOD;
vector<int>::iterator it = operation_search(x);
if(it!=Table[index].end())
Table[index].erase(it);
}
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;
}