Pagini recente » Cod sursa (job #1278677) | Cod sursa (job #2851131) | Cod sursa (job #1989070) | Istoria paginii runda/simulare_oji_viii/clasament | Cod sursa (job #1982077)
#include <fstream>
#include <cstdio>
#include <vector>
#define MOD 666013
using namespace std;
FILE* is=fopen("hashuri.in", "r");
FILE* os=fopen("hashuri.out", "w");
int n, op, x;
vector<int> G[MOD];
vector<int>::iterator find_value(int x);
void add_value(int x);
void remove_value(int x);
int main()
{
fscanf(is, "%d", &n);
for ( int i = 0; i < n; ++i )
{
fscanf(is, "%d %d", &op, &x);
if ( op == 1 )
add_value(x);
else if ( op == 2 )
remove_value(x);
else
fprintf(os, "%d\n", find_value(x) != G[x%MOD].end() );
}
return 0;
}
vector<int>::iterator find_value(int x)
{
int rest = x % MOD;
for ( auto it = G[rest].begin(); it != G[rest].end(); it++)
if ( *it == x )
return it;
return G[rest].end();
}
void add_value(int x)
{
int rest = x % MOD;
if ( find_value(x) == G[rest].end() )
G[rest].push_back(x);
}
void remove_value(int x)
{
int rest = x % MOD;
auto it = find_value(x);
if ( it != G[rest].end() )
G[rest].erase(it);
}