Pagini recente » Cod sursa (job #140672) | Cod sursa (job #805986) | Cod sursa (job #65557) | Cod sursa (job #983525) | Cod sursa (job #2892795)
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#define P 781853
std::ifstream fin("hashuri.in");
std::ofstream fout("hashuri.out");
int main()
{
int n, op, val;
std::vector< std::vector<int> > T(P);
fin >> n;
for (int i = 0; i < n; i++)
{
fin >> op >> val;
int pos = val % P;
std::vector<int>::iterator it = std::find(T[pos].begin(), T[pos].end(), val);
switch (op)
{
case 1:
if (it == T[pos].end())
T[pos].push_back(val);
break;
case 2:
if (it != T[pos].end())
T[pos].erase(it);
break;
case 3:
if (it != T[pos].end())
fout << "1\n";
else
fout << "0\n";
break;
default:
break;
}
}
}