Pagini recente » Cod sursa (job #892189) | Cod sursa (job #93114) | Cod sursa (job #2597446) | Cod sursa (job #432668) | Cod sursa (job #2619192)
#include <bits/stdc++.h>
using namespace std;
const int Dim(1e5);
class InParser {
private:
FILE *fin;
char *buff;
int sp;
char read_ch() {
++sp;
if (sp == Dim) {
sp = 0;
fread(buff, 1, Dim, fin);
}
return buff[sp];
}
public:
InParser(const char* nume) {
fin = fopen(nume, "r");
buff = new char[Dim]();
sp = Dim - 1;
}
InParser& operator >> (int &n) {
char c;
while (!isdigit(c = read_ch()) && c != '-');
int sgn = 1;
if (c == '-') {
n = 0;
sgn = -1;
} else {
n = c - '0';
}
while (isdigit(c = read_ch())) {
n = 10 * n + c - '0';
}
n *= sgn;
return *this;
}
};
class OutParser {
private:
FILE *fout;
char *buff;
int sp;
void write_ch(char ch) {
if (sp == Dim) {
fwrite(buff, 1, Dim, fout);
sp = 0;
buff[sp++] = ch;
} else {
buff[sp++] = ch;
}
}
public:
OutParser(const char* name) {
fout = fopen(name, "w");
buff = new char[Dim]();
sp = 0;
}
~OutParser() {
fwrite(buff, 1, sp, fout);
fclose(fout);
}
OutParser& operator << (int vu32) {
if (vu32 <= 9) {
write_ch(vu32 + '0');
} else {
(*this) << (vu32 / 10);
write_ch(vu32 % 10 + '0');
}
return *this;
}
OutParser& operator << (char ch) {
write_ch(ch);
return *this;
}
OutParser& operator << (const char *ch) {
while (*ch) {
write_ch(*ch);
++ch;
}
return *this;
}
};
InParser fin("hashuri.in");
OutParser fout("hashuri.out");
unordered_map<int, bool> M;
int n, op, x;
int main() {
fin >> n;
M.reserve(n);
for (int i = 1; i <= n; ++i) {
fin >> op >> x;
if (op == 3)
fout << (M.count(x) && M[x]) << '\n';
else M[x] = op & 1;
}
return 0;
}