Pagini recente » Cod sursa (job #123529) | Cod sursa (job #643016) | Cod sursa (job #2157532) | Cod sursa (job #1327324) | Cod sursa (job #2486891)
#include <fstream>
#include <algorithm>
#include <vector>
using namespace std;
ifstream fin("hashuri.in");
ofstream fout("hashuri.out");
const int M = 666013;
vector<int> G[M];
vector<int>::iterator find_elem( int x ) {
vector<int>::iterator it;
int lista = x % M;
for( it = G[lista].begin(); it < G[lista].end(); it ++ )
if( *it == x )
return it;
return G[lista].end();
}
void insert_elem( int x ) {
int lista = x % M;
if( find_elem(x) == G[lista].end() )
G[lista].push_back(x);
}
void erase_elem( int x ) {
int lista = x % M;
vector<int>::iterator it = find_elem(x);
if( it != G[lista].end() )
G[lista].erase(it);
}
int main() {
int n;
fin>>n;
while( n -- ) {
int op, x;
fin>>op>>x;
if( op == 1 )
insert_elem(x);
else if( op == 2 )
erase_elem(x);
else
fout<<!( find_elem(x) == G[x % M].end() )<<"\n";
}
return 0;
}