Pagini recente » Cod sursa (job #3291203) | Cod sursa (job #1671976) | Cod sursa (job #3189902) | Cod sursa (job #2459275) | Cod sursa (job #3287803)
#include <fstream>
#include <ctime>
#include <chrono>
#include <random>
#include <vector>
#include <algorithm>
using namespace std;
ifstream cin("hashuri.in");
ofstream cout("hashuri.out");
mt19937 mt(time(nullptr));
const int nmax = 1e6 + 3;
vector <int> v[nmax];
int rnd[32], q, op, x;
int hsh(int x){
return x%nmax;
}
bool is(int x){
int y = hsh(x);
for(auto it : v[y])
if(it == x) return true;
return false;
}
signed main()
{
for(int i = 0 ; i < 32 ; ++i) rnd[i] = mt();
cin >> q;
while(q--){
cin >> op >> x;
if(op == 1)
if(!is(x)) v[hsh(x)].push_back(x);
if(op == 2){
int y = hsh(x);
if(is(x)) v[y].erase(find(v[y].begin(),v[y].end(),x));
}
if(op == 3){
if(is(x)) cout << 1 << '\n';
else cout << 0 << '\n';
}
}
return 0;
}