Pagini recente » Cod sursa (job #726548) | Cod sursa (job #6296) | Cod sursa (job #2437097) | Cod sursa (job #1894386) | Cod sursa (job #2357442)
/*
** Code by
** ARHIRE ANDREI
*/
#include <bits/stdc++.h>
#define MOD 666013
#define lista x % MOD
using namespace std;
ifstream in ("hashuri.in") ;
ofstream out ("hashuri.out") ;
vector < pair < int , int > > v [ MOD ] ;
pair < int , int > find_element ( int x )
{
vector < pair < int , int > > :: iterator it ;
pair < int , int > sol ;
for ( it = v[ lista ].begin() ; it != v[ lista ].end() ; it ++ )
if ( (*it).first == x )
{
sol.first = (*it).first ;
sol.second = (*it).second ;
return sol ;
}
sol.first = -1 ;
sol.second = -1 ;
return sol ;
}
void push_element ( int x )
{
vector < pair < int , int > > :: iterator it ;
for ( it = v[ lista ].begin() ; it != v[ lista ].end() ; it ++ )
if ( (*it).first == x ) { (*it).second ++ ; return ; }
v [ lista ].push_back( { x , 1 } ) ;
}
int aparitii_element ( int x )
{
vector < pair < int , int > > :: iterator it ;
for ( it = v [ lista ].begin() ; it != v [ lista ].end() ; it ++ )
if ( ( *it ).first == x ) return ( *it ).second ;
}
void delete_aparitie ( int x )
{
vector < pair < int , int > > :: iterator it ;
for ( it = v [ lista ].begin() ; it != v [ lista ].end() ; it ++ )
if ( ( *it ).first == x )
{
( *it ).second -- ;
if ( ( *it ).second == 0 ) v [ lista ].erase(it) ;
return ;
}
}
int n , type , value ;
int main()
{
pair < int , int > X ;
in >> n ;
while ( n -- )
{
in >> type >> value ;
if ( type == 1 ) push_element( value ) ;
if ( type == 2 ) delete_aparitie( value ) ;
if ( type == 3 )
{
X = find_element( value ) ;
if ( X.first == -1 && X.second == -1 ) out << "0\n" ;
else out << "1\n" ; //cout << X.second << '\n' ;
}
}
}