Pagini recente » Cod sursa (job #1342223) | Cod sursa (job #790610) | Cod sursa (job #297420) | Cod sursa (job #993726) | Cod sursa (job #822294)
Cod sursa(job #822294)
# include <fstream>
# include <cstring>
# include <algorithm>
# include <vector>
# define dim 666013
# define mod 666013
using namespace std;
ifstream f("hashuri.in");
ofstream g("hashuri.out");
vector < int > a[ dim ];
int N;
void adauga( int x )
{
if( a[ x % mod ].size() == 0 )
a[ x % mod ].push_back( x );
}
void sterge( int x )
{
if ( a[ x % mod ].size() != 0 )
a[ x % mod ].pop_back();
}
void afiseaza( int x )
{
vector < int > :: iterator it;
int ok = 1;
for ( it = a[ x % mod ].begin() ; it != a[ x % mod ].end() && ok == 1 ; ++it )
if ( *it == x )
{
g << 1 << "\n";
ok = 0;
}
if ( ok == 1 )
g << 0 << "\n";
}
void citire()
{
int op, x, i;
f >> N;
for ( i = 1 ; i <= N ; i++ )
{
f >> op >> x;
if ( op == 1 )
adauga( x );
else
if ( op == 2 )
sterge( x );
else
if ( op == 3 )
afiseaza( x );
}
}
int main()
{
citire();
}