Pagini recente » Cod sursa (job #2044641) | Cod sursa (job #1257890) | Cod sursa (job #938814) | Cod sursa (job #1619037) | Cod sursa (job #675439)
Cod sursa(job #675439)
#include <fstream>
#include <list>
using namespace std;
ifstream fi ("hashuri.in");
ofstream fo ("hashuri.out");
const int mod = 882377;
list <int> H[mod+5];
list <int> :: iterator p;
void cauta (int x, int h)
{
for (p = H[h].begin(); p != H[h].end(); p++)
if (*p == x)
return;
p = NULL;
}
int main ()
{
int t, x, n, h;
fi >> n;
while ( n-- )
{
fi >> t >> x;
h = x % mod;
if (t == 1)
{
cauta (x, h);
if (p == NULL)
H[h].push_back (x);
}
else if (t == 2)
{
cauta (x, h);
if (p != NULL)
H[h].erase (p);
}
else if (t == 3)
{
cauta (x, h);
fo << (p != NULL) << '\n';
}
}
return 0;
}