Pagini recente » Cod sursa (job #1224532) | Cod sursa (job #966020) | Cod sursa (job #566141) | Cod sursa (job #3160136) | Cod sursa (job #1039437)
#include <iostream>
#include <vector>
#include <fstream>
#define nmax 1000005
#define loc x%P
using namespace std;
ifstream in("hashuri.in");
ofstream out("hashuri.out");
long N, key, x;
const long P = 666013;
vector <long> H[P];
bool find(int x)
{
for ( unsigned int i=0; i < H[loc].size(); ++i )
if ( H[loc][i] == x ) return 1;
return 0;
}
void insert(int x)
{
if ( !find(x) )
H[loc].push_back(x);
}
void erase(int x)
{
for ( unsigned int i=0; i < H[loc].size(); ++i )
if ( H[loc][i] == x )
{
H[loc][i] = H[loc].back();
H[loc].pop_back();
}
}
int main()
{
in >> N;
for ( int i=1; i<=N; ++i )
{
in >> key >> x;
if ( key == 1 ) insert(x);
if ( key == 2 ) erase(x);
if ( key == 3 ) out << find(x) << '\n';
}
return 0;
}