Pagini recente » Cod sursa (job #1105951) | Cod sursa (job #3151049) | Cod sursa (job #2169489) | Cod sursa (job #3149057) | Cod sursa (job #1193464)
#include <cstdio>
#include <vector>
using namespace std;
#define MOD 666013
#define LL long long
vector < LL > H[MOD];
LL type,N,X;
vector < LL > :: iterator it;
int main()
{
freopen("hashuri.in","r",stdin);
freopen("hashuri.out","w",stdout);
scanf("%lld",&N);
while (N--)
{
scanf("%lld",&type);
scanf("%lld",&X);
for (it=H[X%MOD].begin();it!=H[X%MOD].end();++it)
if (*it==X) break;
if (type==1)
{
if (!H[X%MOD].empty() && *it==X) continue;
H[X%MOD].push_back(X);
continue;
}
if (type==2)
{
if (H[X%MOD].empty() || it==H[X%MOD].end()) continue;
H[X%MOD].erase(it);
continue;
}
if (!H[X%MOD].empty() && *it==X) printf("1\n");
else printf("0\n");
}
return 0;
}