Pagini recente » Cod sursa (job #3163621) | Cod sursa (job #900400) | Cod sursa (job #911516) | Cod sursa (job #477454) | Cod sursa (job #2196493)
#include <bits/stdc++.h>
#define MOD 666013
using namespace std;
ifstream f("hashuri.in");
ofstream g("hashuri.out");
int N, tip, x;
vector<int> H[MOD];
std::vector<int>::iterator find(int x, int shelf) {
auto it = H[shelf].begin();
for( ; it != H[shelf].end(); it++)
if(*it == x) return it;
return it;
}
int main()
{
f >> N;
for(int i = 1; i <= N; i++) {
f >> tip >> x;
int shelf = x % MOD;
auto poz = find(x, shelf);
if(tip == 1 && poz == H[shelf].end()) H[shelf].push_back(x);
else if(tip == 2 && poz != H[shelf].end()) H[shelf].erase(poz);
else if(tip == 3) g << (poz != H[shelf].end()) << "\n";
}
return 0;
}