Pagini recente » Cod sursa (job #2949119) | Cod sursa (job #1255018) | Cod sursa (job #58438) | Cod sursa (job #2260884) | Cod sursa (job #1804793)
#include <algorithm>
#include <iostream>
#include <fstream>
#include <cstring>
#include <vector>
#include <set>
#define MOD 666667
using namespace std;
ifstream f("hashuri.in" );
ofstream g("hashuri.out");
vector<int> table[MOD];
inline void addElem(int x) {
int poz = x%MOD;
vector<int>::iterator it = find(table[poz].begin(), table[poz].end(), x);
if ( it == table[poz].end() )
table[poz].push_back(x);
}
void delElem(int x) {
int poz = x%MOD;
vector<int>::iterator it = find(table[poz].begin(), table[poz].end(), x);
if ( it != table[poz].end() )
table[poz].erase(it);
}
inline void queryElem(int x) {
int poz = x%MOD;
vector<int>::iterator it = find(table[poz].begin(), table[poz].end(), x);
if ( it != table[poz].end() )
g << 1 << '\n';
else
g << 0 << '\n';
}
int NrOperatii;
int main()
{
f >> NrOperatii; int op, x;
for ( int i=1; i<=NrOperatii; i++ )
{
f >> op >> x;
switch ( op )
{
case 1: addElem(x); break;
case 2: delElem(x); break;
case 3: queryElem(x); break;
}
}
}