Pagini recente » Cod sursa (job #834561) | Cod sursa (job #2331717) | Cod sursa (job #2356381) | Cod sursa (job #2492729) | Cod sursa (job #922296)
Cod sursa(job #922296)
# include <fstream>
# include <vector>
# define mod 666013
using namespace std;
int n;
vector< vector< int > > mat ( mod);
inline vector<int>::iterator find_value( int x )
{
int list = x % mod;
vector<int>::iterator it;
for (it = mat[ list ].begin(); it != mat[ list ].end(); ++it )
if ( *it == x )
return it;
return mat[ list ].end();
}
inline void insert_value( int x )
{
int list = x % mod;
if ( find_value( x ) == mat[ list ].end() )
mat[ list ].push_back(x);
}
inline void erase_value(int x)
{
int list = x % mod;
vector<int>::iterator it = find_value(x);
if ( it != mat[ list ].end() )
mat[ list ].erase(it);
}
int main()
{
ifstream fin("hashuri.in");
ofstream fout("hashuri.out");
fin >> n;
for( ; n; --n )
{
int op, x;
fin >> op >> x;
if (op == 1)
insert_value(x);
else
if (op == 2)
erase_value(x);
else
if(op == 3 && find_value(x) != mat[ x % mod ].end() )
fout <<"1\n";
else
fout <<"0\n";
}
}