Pagini recente » Cod sursa (job #1256789) | Cod sursa (job #2548830) | Cod sursa (job #1034260) | Cod sursa (job #1902571) | Cod sursa (job #1413831)
#include <fstream>
#include <vector>
using namespace std;
const int mod = 666013;
ifstream fin("hashuri.in");
ofstream fout("hashuri.out");
int m, t, x;
vector <int> v[mod];
vector <int> :: iterator findValue(int x)
{
int list = x % mod;
vector <int> :: iterator it;
for (it = v[list].begin(); it != v[list].end(); ++it)
{
if (*it == x) return it;
}
return v[list].end();
}
void insertValue(int x)
{
int list = x % mod;
if (findValue(x) == v[list].end())
v[list].push_back(x);
}
void eraseValue(int x)
{
int list = x % mod;
vector <int> :: iterator it;
it = findValue(x);
if (it != v[list].end())
v[list].erase(it);
}
int main()
{
fin >> m;
for (; m; --m)
{
fin >> t >> x;
if (t == 1) insertValue(x);
else if (t == 2) eraseValue(x);
else fout << (findValue(x) != v[x % mod].end()) << '\n';
}
return 0;
}