Pagini recente » Cod sursa (job #1382849) | Cod sursa (job #2367532) | Cod sursa (job #1448894) | Cod sursa (job #2047931) | Cod sursa (job #2223925)
#include <bits/stdc++.h>
using namespace std;
class Reader {
public:
Reader(const string& filename):
m_stream(filename),
m_pos(kBufferSize - 1),
m_buffer(new char[kBufferSize]) {
next();
}
Reader& operator>>(int& value) {
value = 0;
while (current() < '0' || current() > '9')
next();
while (current() >= '0' && current() <= '9') {
value = value * 10 + current() - '0';
next();
}
return *this;
}
private:
const int kBufferSize = 32768;
char current() {
return m_buffer[m_pos];
}
void next() {
if (!(++m_pos != kBufferSize)) {
m_stream.read(m_buffer.get(), kBufferSize);
m_pos = 0;
}
}
ifstream m_stream;
int m_pos;
unique_ptr<char[]> m_buffer;
};
set <int> s;
int main() {
Reader fin ("hashuri.in");
ofstream fout ("hashuri.out");
int n;
fin >> n;
for (int i = 1; i <= n; ++i) {
int tip, x;
fin >> tip >> x;
if (tip == 1) {
s.insert(x);
}
if (tip == 2) {
s.erase(x);
}
if (tip == 3) {
if (s.find(x) != s.end()) {
cout << 1 << '\n';
} else {
cout << 0 << '\n';
}
}
}
return 0;
}