Pagini recente » Cod sursa (job #2107847) | Cod sursa (job #814519) | Cod sursa (job #1585139) | Cod sursa (job #897052) | Cod sursa (job #730327)
Cod sursa(job #730327)
//============================================================================
// Name : HashTables2.cpp
// Author : Petrisor Teodora
// Version :
// Copyright :
// Description : problem hashuri infoarena
//============================================================================
#include <iostream>
#include <fstream>
#include <set>
# define P 16863
using namespace std;
set<int>S[P+10];
int main() {
ifstream input("hashuri.in");
ofstream output("hashuri.out");
int n;
input>>n; // read the number of pairs
int op, x;
for (int i = 0; i < n; ++i)
{
input>>op>>x; // read the pair (operation, number)
if(op==1)
S[x%P].insert(x);
if(op==2)
S[x%P].erase(x);
if(op == 3)
{
if(S[x%P].find(x) != S[x%P].end())
output<<"1\n";
else
output<<"0\n";
}
}
return 0;
}