Pagini recente » Cod sursa (job #1411111) | Cod sursa (job #1473011) | Cod sursa (job #3294431) | Cod sursa (job #814073) | Cod sursa (job #675449)
Cod sursa(job #675449)
#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 = H[mod].begin();
}
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 == H[mod].begin())
H[h].push_back (x);
}
else if (t == 2)
{
cauta (x, h);
if (p != H[mod].begin())
H[h].erase (p);
}
else if (t == 3)
{
cauta (x, h);
fo << (p != H[mod].begin()) << '\n';
}
}
return 0;
}