#3798
NrMinMaxAp
C++
Scrieți funcția care are antetul:
int NrMinMaxAp(vector<int> &a)
Funcția va returna numărul care apare de cele mai multe ori în a
. Dacă există mai multe numere care apar de număr maxim de ori, se va returna minimul dintre ele.
Problema | NrMinMaxAp | Operații I/O |
nrminmaxap.in /nrminmaxap.out
|
---|---|---|---|
Limita timp | 0.3 secunde | Limita memorie |
Total: 256 MB
/
Stivă 128 MB
|
Id soluție | #50206656 | Utilizator | |
Fișier | nrminmaxap.cpp | Dimensiune | 270 B |
Data încărcării | 31 Martie 2024, 20:01 | Scor / rezultat | Eroare de compilare |
nrminmaxap.cpp:10:16: error: conflicting declaration 'std::map<std::basic_string<char>, int> a' map<string,int>a; ^ nrminmaxap.cpp:4:13: error: 'a' has a previous declaration as 'std::vector<int> a' vector<int> a; ^ nrminmaxap.cpp: In function 'int main()': nrminmaxap.cpp:17:6: error: no match for 'operator[]' (operand types are 'std::vector<int>' and 'std::string {aka std::basic_string<char>}') a[s]++; ^ nrminmaxap.cpp:17:6: note: candidates are: In file included from /usr/include/c++/4.8/vector:64:0, from /usr/include/c++/4.8/bits/random.h:34, from /usr/include/c++/4.8/random:50, from /usr/include/c++/4.8/bits/stl_algo.h:65, from /usr/include/c++/4.8/algorithm:62, from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:64, from nrminmaxap.cpp:1: /usr/include/c++/4.8/bits/stl_vector.h:770:7: note: std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](std::vector<_Tp, _Alloc>::size_type) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::reference = int&; std::vector<_Tp, _Alloc>::size_type = unsigned int] operator[](size_type __n) ^ /usr/include/c++/4.8/bits/stl_vector.h:770:7: note: no known conversion for argument 1 from 'std::string {aka std::basic_string<char>}' to 'std::vector<int>::size_type {aka unsigned int}' /usr/include/c++/4.8/bits/stl_vector.h:785:7: note: std::vector<_Tp, _Alloc>::const_reference std::vector<_Tp, _Alloc>::operator[](std::vector<_Tp, _Alloc>::size_type) const [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::const_reference = const int&; std::vector<_Tp, _Alloc>::size_type = unsigned int] operator[](size_type __n) const ^ /usr/include/c++/4.8/bits/stl_vector.h:785:7: note: no known conversion for argument 1 from 'std::string {aka std::basic_string<char>}' to 'std::vector<int>::size_type {aka unsigned int}' nrminmaxap.cpp:18:9: error: no match for 'operator[]' (operand types are 'std::vector<int>' and 'std::string {aka std::basic_string<char>}') if(a[s]>mx) ^ nrminmaxap.cpp:18:9: note: candidates are: In file included from /usr/include/c++/4.8/vector:64:0, from /usr/include/c++/4.8/bits/random.h:34, from /usr/include/c++/4.8/random:50, from /usr/include/c++/4.8/bits/stl_algo.h:65, from /usr/include/c++/4.8/algorithm:62, from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:64, from nrminmaxap.cpp:1: /usr/include/c++/4.8/bits/stl_vector.h:770:7: note: std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](std::vector<_Tp, _Alloc>::size_type) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::reference = int&; std::vector<_Tp, _Alloc>::size_type = unsigned int] operator[](size_type __n) ^ /usr/include/c++/4.8/bits/stl_vector.h:770:7: note: no known conversion for argument 1 from 'std::string {aka std::basic_string<char>}' to 'std::vector<int>::size_type {aka unsigned int}' /usr/include/c++/4.8/bits/stl_vector.h:785:7: note: std::vector<_Tp, _Alloc>::const_reference std::vector<_Tp, _Alloc>::operator[](std::vector<_Tp, _Alloc>::size_type) const [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::const_reference = const int&; std::vector<_Tp, _Alloc>::size_type = unsigned int] operator[](size_type __n) const ^ /usr/include/c++/4.8/bits/stl_vector.h:785:7: note: no known conversion for argument 1 from 'std::string {aka std::basic_string<char>}' to 'std::vector<int>::size_type {aka unsigned int}' nrminmaxap.cpp:19:13: error: no match for 'operator[]' (operand types are 'std::vector<int>' and 'std::string {aka std::basic_string<char>}') mx=a[s]; ^ nrminmaxap.cpp:19:13: note: candidates are: In file included from /usr/include/c++/4.8/vector:64:0, from /usr/include/c++/4.8/bits/random.h:34, from /usr/include/c++/4.8/random:50, from /usr/include/c++/4.8/bits/stl_algo.h:65, from /usr/include/c++/4.8/algorithm:62, from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:64, from nrminmaxap.cpp:1: /usr/include/c++/4.8/bits/stl_vector.h:770:7: note: std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](std::vector<_Tp, _Alloc>::size_type) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::reference = int&; std::vector<_Tp, _Alloc>::size_type = unsigned int] operator[](size_type __n) ^ /usr/include/c++/4.8/bits/stl_vector.h:770:7: note: no known conversion for argument 1 from 'std::string {aka std::basic_string<char>}' to 'std::vector<int>::size_type {aka unsigned int}' /usr/include/c++/4.8/bits/stl_vector.h:785:7: note: std::vector<_Tp, _Alloc>::const_reference std::vector<_Tp, _Alloc>::operator[](std::vector<_Tp, _Alloc>::size_type) const [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::const_reference = const int&; std::vector<_Tp, _Alloc>::size_type = unsigned int] operator[](size_type __n) const ^ /usr/include/c++/4.8/bits/stl_vector.h:785:7: note: no known conversion for argument 1 from 'std::string {aka std::basic_string<char>}' to 'std::vector<int>::size_type {aka unsigned int}' nrminmaxap.cpp: In function 'int main()': nrminmaxap.cpp:27:5: error: redefinition of 'int main()' int main() ^ nrminmaxap.cpp:12:5: error: 'int main()' previously defined here int main() ^ nrminmaxap.cpp:36:25: error: 'NrMinMaxAp' was not declared in this scope fout << NrMinMaxAp(a) << "\n"; ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema NrMinMaxAp face parte din a doua categorie. Pentru aceste probleme se folosește un program suport, furnizat de propunătorul problemei. Soluția propusă de tine va fi evaluată astfel:
Suma punctajelor acordate pe testele utilizate pentru verificare este 100. Astfel, soluția ta poate obține cel mult 100 de puncte, caz în care se poate considera corectă.