Pagini recente » Cod sursa (job #1908740) | Cod sursa (job #1519535) | Cod sursa (job #2119481) | Cod sursa (job #2749415) | Cod sursa (job #1321250)
#include <fstream>
#include <list>
#define NRM 500009
using namespace std;
ifstream f("hashuri.in");
ofstream g("hashuri.out");
long N, tip, x, m, ex, i;
list<long> lista[NRM];
list<long>::iterator it;
int main()
{
f >> N;
for( i=1; i <= N ; i++){
f >> tip >> x;
m = x % NRM;
ex=0;
for(it = lista[m].begin();it != lista[m].end(); it++ ){
if((*it)==x){
if(tip == 2)
lista[m].erase( it );
ex = *it;
break;
}
}
if( tip == 1 && !ex)
lista[m].push_back(x);
if( tip == 3)
g << (ex!=0) << '\n';
}
}