Detalii evaluare #49407221

Rezumat problemă

#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.

Detalii

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 #49407221 Utilizator Soreanu Dumitru Paul (pds810930)
Fișier nrminmaxap.cpp Dimensiune 319 B
Data încărcării 29 Februarie 2024, 11:11 Scor / rezultat Eroare de compilare

Evaluare


Mesaj compilare

nrminmaxap.cpp: In function 'int NrMinMaxAp(std::vector<int>&)':
nrminmaxap.cpp:10:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0; i<a.size(); i++)

                           ^
nrminmaxap.cpp:14:20: error: no match for 'operator[]' (operand types are 'std::unordered_map<int, int>' and 'std::pair<const int, int>')
         if(aparitii[i]>maxim)

                    ^
nrminmaxap.cpp:14:20: note: candidates are:
In file included from /usr/include/c++/4.8/unordered_map:48:0,
                 from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:115,
                 from nrminmaxap.cpp:1:
/usr/include/c++/4.8/bits/unordered_map.h:595:7: note: std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::mapped_type& std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator[](const key_type&) [with _Key = int; _Tp = int; _Hash = std::hash<int>; _Pred = std::equal_to<int>; _Alloc = std::allocator<std::pair<const int, int> >; std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::mapped_type = int; std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::key_type = int]
       operator[](const key_type& __k)
       ^
/usr/include/c++/4.8/bits/unordered_map.h:595:7: note:   no known conversion for argument 1 from 'std::pair<const int, int>' to 'const key_type& {aka const int&}'
/usr/include/c++/4.8/bits/unordered_map.h:599:7: note: std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::mapped_type& std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator[](std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::key_type&&) [with _Key = int; _Tp = int; _Hash = std::hash<int>; _Pred = std::equal_to<int>; _Alloc = std::allocator<std::pair<const int, int> >; std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::mapped_type = int; std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::key_type = int]
       operator[](key_type&& __k)
       ^
/usr/include/c++/4.8/bits/unordered_map.h:599:7: note:   no known conversion for argument 1 from 'std::pair<const int, int>' to 'std::unordered_map<int, int>::key_type&& {aka int&&}'
nrminmaxap.cpp:16:24: error: no match for 'operator[]' (operand types are 'std::unordered_map<int, int>' and 'std::pair<const int, int>')
          maxim=aparitii[i];

                        ^
nrminmaxap.cpp:16:24: note: candidates are:
In file included from /usr/include/c++/4.8/unordered_map:48:0,
                 from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:115,
                 from nrminmaxap.cpp:1:
/usr/include/c++/4.8/bits/unordered_map.h:595:7: note: std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::mapped_type& std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator[](const key_type&) [with _Key = int; _Tp = int; _Hash = std::hash<int>; _Pred = std::equal_to<int>; _Alloc = std::allocator<std::pair<const int, int> >; std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::mapped_type = int; std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::key_type = int]
       operator[](const key_type& __k)
       ^
/usr/include/c++/4.8/bits/unordered_map.h:595:7: note:   no known conversion for argument 1 from 'std::pair<const int, int>' to 'const key_type& {aka const int&}'
/usr/include/c++/4.8/bits/unordered_map.h:599:7: note: std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::mapped_type& std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator[](std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::key_type&&) [with _Key = int; _Tp = int; _Hash = std::hash<int>; _Pred = std::equal_to<int>; _Alloc = std::allocator<std::pair<const int, int> >; std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::mapped_type = int; std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::key_type = int]
       operator[](key_type&& __k)
       ^
/usr/include/c++/4.8/bits/unordered_map.h:599:7: note:   no known conversion for argument 1 from 'std::pair<const int, int>' to 'std::unordered_map<int, int>::key_type&& {aka int&&}'
nrminmaxap.cpp:17:13: error: cannot convert 'std::pair<const int, int>' to 'int' in assignment
          rez=i;

             ^

Cum funcționează evaluarea?

www.pbinfo.ro permite evaluarea a două tipuri de probleme:

  • probleme la care rezolvarea presupune scrierea unui program complet
  • probleme la care rezolvarea presupune scrierea unei secvențe de program - câteva instrucțiuni, o listă de declarații, una sau mai multe funcții, etc.

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:

  • Soluția propusă de tine este inclusă în programul suport, apoi acesta este compilat. Dacă în urma compilării se obțin erori sau avertismente, acestea sunt afișate în această pagină.
  • Datorită existenței programului suport, la compilare pot să apară erori sau avertismente care să nu se refere la instrucțiunile scrise de tine, dar care sunt datorate faptului că soluția ta nu este corectă.
  • Dacă programul suport a fost compilat, executabilul obținut va fi rulat, furnizându-i-se unul sau mai multe seturi de date de intrare, în concordanță cu restricțiile specifice problemei. Pentru fiecare set de date se obține un anumit punctaj, în raport cu corectitudinea soluției tale.

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ă.