Pagini recente » Cod sursa (job #877945) | ccex-2013-clasa-a-10-a | Cod sursa (job #622239) | Cod sursa (job #1861298) | Cod sursa (job #1649045)
#include <fstream>
#define PRIM 666013
#include <list>
typedef long long ll;
using namespace std;
list <ll> liste[PRIM];
ll x;
int tip, n, found, ind;
list <ll>::iterator it;
int main()
{
ifstream in("hashuri.in");
ofstream out("hashuri.out");
in>>n;
for(int i = 1; i <= n; ++i){
found = 0;
in>>tip>>x;
ind = x % PRIM;
if(tip == 1){
for(it = liste[ind].begin(); it != liste[ind].end(); ++it){
if(*it == x)
found = 1;
}
if(!found || liste[ind].empty()) liste[ind].push_back(x);
}
if(tip == 2){
for(it = liste[ind].begin(); it != liste[ind].end(); ++it){
if(*it == x){
liste[ind].erase(it);
break;
}
}
}
if(tip == 3){
for(it = liste[ind].begin(); it != liste[ind].end(); ++it){
if(*it == x)
found = 1;
}
out<<found<<"\n";
}
}
in.close();
out.close();
return 0;
}