Pagini recente » Cod sursa (job #2978113) | Cod sursa (job #882639) | Cod sursa (job #2721575) | Cod sursa (job #1027357) | Cod sursa (job #998189)
Cod sursa(job #998189)
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <fstream>
#include <iterator>
using namespace std;
const string file = "hashuri";
const string infile = file + ".in";
const string outfile = file + ".out";
const int INF = 0x3f3f3f3f;
vector<vector<int> > L;
const int MODN = 66697;
inline int modul(int x)
{
return x % MODN;
}
void insert(int x)
{
int h = modul(x);
bool found = false;
for(vector<int>::iterator itr = L[h].begin();
itr != L[h].end();
itr++)
{
if(*itr == x)
{
found = true;
break;
}
}
if(found == false)
L[h].push_back(x);
}
void elimina(int x)
{
int h = modul(x);
bool found = false;
for(vector<int>::iterator itr = L[h].begin();
itr != L[h].end();
itr++)
{
if(*itr == x)
{
iter_swap(itr, L[h].end() - 1);
L[h].pop_back();
return;
}
}
}
bool is(int x)
{
int h = modul(x);
bool found = false;
for(vector<int>::iterator itr = L[h].begin();
itr != L[h].end();
itr++)
{
if(*itr == x)
{
found = true;
break;
}
}
return found;
}
int main()
{
fstream fout(outfile.c_str(), ios::out);
fstream fin(infile.c_str(), ios::in);
int N;
fin >> N;
L.resize(MODN);
for(int i = 0; i < N; i++)
{
int op, x;
fin >> op >> x;
switch(op)
{
case 1:
insert(x);
break;
case 2:
elimina(x);
break;
case 3:
fout << (is(x) == true ? 1 : 0) << "\n";
break;
}
}
fin.close();
fout.close();
}