Pagini recente » Istoria paginii runda/cdib_8910 | Cod sursa (job #2072790) | Cod sursa (job #1428343) | Arhiva de probleme | Cod sursa (job #1997768)
#include <unordered_set>
#include <bits/stdc++.h>
using namespace std;
int N;
unordered_set<int> A;
const int kBuffSize = 655536;
#define fastcall __attribute__((optimize("-O3")))
#define inline __inline__ __attribute__((always_inline))
inline fastcall char getChar()
{
static char buff[kBuffSize];
static int pos = kBuffSize;
if (pos == kBuffSize)
{
fread(buff, 1, kBuffSize, stdin);
pos = 0;
}
return buff[pos++];
}
inline fastcall int readInt()
{
int q = 0;
char c;
do
{
c = getChar();
}
while (!isdigit(c));
do
{
q = (q << 1) + (q << 3) + (c - '0');
c = getChar();
}
while (isdigit(c));
return q;
}
char outBuff[kBuffSize];
int outPtr;
inline fastcall void putChar(const char &C)
{
outBuff[outPtr++] = C;
if (outPtr == kBuffSize)
{
fwrite(outBuff, 1, kBuffSize, stdout);
outPtr = 0;
}
}
inline fastcall void writeInt(int X)
{
char digs[10];
int n = 0, q;
do
{
q = X / 10;
digs[n++] = X - (q << 1) - (q << 3) + '0';
X = q;
}
while (X);
while (n--)
{
putChar(digs[n]);
}
putChar('\n');
}
#define M ((1 << 21) + 1)
vector<int> v[M];
int h(int x)
{
return x % M;
}
bool src(int x)
{
return v[h(x)].end() != find(v[h(x)].begin(), v[h(x)].end(), x);
}
void del(int x)
{
if (src(x))
{
auto pos = find(v[h(x)].begin(), v[h(x)].end(), x);
v[h(x)].erase(pos);
}
}
void ins(int x)
{
if (!src(x))
{
v[h(x)].push_back(x);
}
}
int main()
{
freopen("hashuri.in", "r", stdin);
freopen("hashuri.out", "w", stdout);
int op, x;
for (N = readInt(); N; --N)
{
op = readInt();
x = readInt();
if (op == 1)
{
ins(x);
continue;
}
if (op == 2)
{
del(x);
continue;
}
writeInt(src(x));
}
fclose(stdin);
fwrite(outBuff, 1, outPtr, stdout);
fclose(stdout);
return 0;
}