Pagini recente » Cod sursa (job #1516376) | Cod sursa (job #504910) | Cod sursa (job #1977137) | Cod sursa (job #3166814) | Cod sursa (job #1021363)
#include<iostream>
#include<fstream>
#include<vector>
using namespace std;
#define PRIM 113
vector<int>h[PRIM];
int n;
void solve(){
ifstream fin ("hashuri.in");
ofstream fout ("hashuri.out");
fin >> n;
int cmd, x;
for(int i=1; i<=n; i++){
fin >> cmd >> x;
if(cmd == 1){
h[x%PRIM].push_back(x);
}else if(cmd == 2){
int pos = -1;
for(size_t i=0; i<h[x%PRIM].size(); i++){
if(h[x%PRIM][i] == x) {pos = i; break;}
}
if(pos != -1)
h[x%PRIM].erase(h[x%PRIM].begin() + pos);
}else {
bool found = false;
for(size_t i=0; i<h[x%PRIM].size(); i++){
if(h[x%PRIM][i] == x){found = true; break;}
}
if(found){
fout << 1 << '\n';
}else fout << 0 << '\n';
}
}
}
int main(){
solve();
return 0;
}