Pagini recente » Cod sursa (job #717455) | Cod sursa (job #1664000) | Cod sursa (job #618989) | Cod sursa (job #2300663) | Cod sursa (job #1921523)
#include <iostream>
#include <fstream>
#include <unordered_map>
using namespace std;
class parser{
public:
parser() {}
parser(const char *file_name){
input_file.open(file_name,ios::in | ios::binary);
input_file.sync_with_stdio(false);
index=0;
input_file.read(buffer,SIZE);}
inline parser &operator >>(int &n){
for (;buffer[index]<'0' or buffer[index]>'9';inc());
n=0;
for (;'0'<=buffer[index] and buffer[index]<='9';inc())
n=10*n+buffer[index]-'0';
return *this;}
~parser(){
input_file.close();}
private:
fstream input_file;
static const int SIZE=0x400000;
char buffer[SIZE];
int index=0;
inline void inc(){
if(++index==SIZE)
index=0,input_file.read(buffer,SIZE);}
};
class writer{
public:
writer() {};
writer(const char *file_name){
output_file.open(file_name,ios::out | ios::binary);
output_file.sync_with_stdio(false);
index=0;}
inline writer &operator <<(int target){
aux=0;
n=target;
if (!n)
nr[aux++]='0';
for (;n;n/=10)
nr[aux++]=n%10+'0';
for(;aux;inc())
buffer[index]=nr[--aux];
return *this;}
inline writer &operator <<(const char *target){
aux=0;
while (target[aux])
buffer[index]=target[aux++],inc();
return *this;}
~writer(){
output_file.write(buffer,index);output_file.close();}
private:
fstream output_file;
static const int SIZE=0x200000;
int index=0,aux,n;
char buffer[SIZE],nr[24];
inline void inc(){
if(++index==SIZE)
index=0,output_file.write(buffer,SIZE);}
};
parser f ("hashuri.in");
writer t ("hashuri.out");
typedef unordered_map <int,bool> int_hash;
int main()
{
int_hash table;
int n;
f>>n;
for (int type,target;n;--n){
f>>type>>target;
if (type==1)
table.emplace(target,true);
else if (type==2)
table[target]=false;
else if (type==3)
t<<table[target]<<"\n";
}
return 0;
}