Cod sursa(job #2596794)
| Utilizator | Data | 10 aprilie 2020 13:56:15 | |
|---|---|---|---|
| Problema | Hashuri | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 1.35 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream fin("hashuri.in");
ofstream fout("hashuri.out");
int n;
vector<int> keys[1000000];
int main()
{
fin >> n;
while(n--){
int task;
fin >> task;
if(task == 1){
int x;
fin >> x;
int modulo = x % 1000000;
bool good = false;
for(auto it:keys[modulo]){
if(it == x){
good = true;
break;
}
}
if(!good) keys[modulo].push_back(x);
}
else if(task == 2){
int x;
fin >> x;
int modulo = x % 1000000;
int sz = keys[modulo].size();
for(int i = 0; i < sz; ++i){
if(keys[modulo][i] == x){
keys[modulo].erase(keys[modulo].begin() + i);
break;
}
}
}
else{
int x;
fin >> x;
int modulo = x % 1000000;
bool good = false;
for(auto it:keys[modulo]){
if(it == x){
good = true;
break;
}
}
fout << (good ? 1 : 0) << "\n";
}
}
return 0;
}
