Pagini recente » Statistici Taylor Swift (NoBodyNoCrime) | Istoria paginii runda/mnmxmnmxmnmx_what | Cod sursa (job #1735079) | Istoria paginii runda/simulare-cartita-26/clasament | Cod sursa (job #1970138)
#include <bits/stdc++.h>
using namespace std;
const int SIZE = 100000;
class InParser {
char buffer[SIZE];
int pos;
char next_char(){
if(pos == SIZE){
pos = 0;
fread(buffer, 1, SIZE, stdin);
}
return buffer[pos++];
}
public:
InParser(){
pos = 0;
fread(buffer, 1, SIZE, stdin);
}
InParser& operator>>(int &x){
x = 0;
char c = next_char();
while(c < '0' || c > '9'){
c = next_char();
}
while(c >= '0' && c <='9'){
x = x * 10 + c - '0';
c = next_char();
}
return *this;
}
};
const int MAXN = 1000001;
const int MOD = 666013;
vector<int> h[MOD];
bool hash_find(int nod){
int where = nod % MOD;
return find(h[where].begin(), h[where].end(), nod) != h[where].end();
}
void hash_insert(int nod){
int where = nod % MOD;
if(!hash_find(nod)){
h[where].push_back(nod);
}
}
void hash_remove(int nod){
int where = nod % MOD;
auto it = find(h[where].begin(), h[where].end(), nod);
if(it == h[where].end())
return;
h[where].erase(it);
}
int q;
int main(){
freopen("hashuri.in", "r", stdin);
freopen("hashuri.out", "w", stdout);
InParser in;
in>>q;
while(q--){
int op, param;
in>>op>>param;
if(op == 1){
hash_insert(param);
} else if(op == 2){
hash_remove(param);
} else {
printf("%d\n", hash_find(param));
}
}
}