Pagini recente » Cod sursa (job #1511044) | Cod sursa (job #792326) | Cod sursa (job #1523739) | Cod sursa (job #233708) | Cod sursa (job #1502431)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("hashuri.in");
ofstream fout("hashuri.out");
const int MOD = 666013;
const int BMax = 30;
vector < int > Hash[MOD];
inline vector < int > ::iterator Search(const int &x){
vector < int > ::iterator it;
int line = x % MOD;
for(it = Hash[line].begin(); it != Hash[line].end(); it++){
if(*it == x){
return it;
}
}
return Hash[line].end();
}
int pos = BMax - 1;
char buffer[BMax];
inline void Read(int &x){
while(!isdigit(buffer[pos])){
pos++;
if(pos == BMax){
fin.getline(buffer, BMax, '\n');
pos = 0;
}
}
x = 0;
while(isdigit(buffer[pos])){
x = x * 10 + (buffer[pos] - '0');
pos++;
if(pos == BMax){
fin.getline(buffer, BMax, '\n');
pos = 0;
}
}
}
int main(){
vector < int > ::iterator ans;
int n, type, x;
Read(n);
while(n--){
Read(type); Read(x);
ans = Search(x);
if(type == 1){
if(ans == Hash[x % MOD].end()){
Hash[x % MOD].push_back(x);
}
} else {
if(type == 2){
if(ans != Hash[x % MOD].end()){
Hash[x % MOD].erase(ans);
}
} else {
if(ans == Hash[x % MOD].end()){
fout << "0\n";
} else {
fout << "1\n";
}
}
}
}
return 0;
}