Cod sursa(job #2892289)
| Utilizator | Data | 21 aprilie 2022 17:01:46 | |
|---|---|---|---|
| Problema | Hashuri | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 1.3 kb |
#include<fstream>
#include<vector>
#define M 524287
using namespace std;
ifstream fin("hashuri.in");
ofstream fout("hashuri.out");
vector<int> hashuri[M];
int n, x, y, k, ok;
int main(){
fin>>n;
for(int i=1; i<=n; i++){
fin>>x>>y;
k=y%M;
if(x==1){
ok=1;
for(int j=0; j<hashuri[k].size(); j++){
if(hashuri[k][j]==y){
ok=0;
break;
}
}
if(ok==1)
hashuri[k].push_back(y);
}
else{
if(x==2){
for(int j=0; j<hashuri[k].size(); j++){
if(hashuri[k][j]==y){
hashuri[k].erase(hashuri[k].begin()+j);
}
}
}
else{
if(x==3){
ok=0;
for(int j=0; j<hashuri[k].size(); j++){
if(hashuri[k][j]==y){
ok=1;
fout<<1<<"\n";
break;
}
}
if(ok==0){
fout<<0<<"\n";
}
}
}
}
}
}
