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