Detalii evaluare #49110671

Rezumat problemă

#1705 Farma

Noile reguli din sistemul sanitar cer ca medicii să nu prescrie pe reţete un anumit medicament, ci să menţioneze substanţa activă. Reţeta este formată din n prescripţii, câte una pentru fiecare substanţă activă prescrisă.

Farmacista de la care cumpăr medicamentele mi-a făcut o listă în care pentru fiecare substanţă activă de pe reţetă sunt trecute medicamentele care conţin substanţa activă respectivă, precum şi preţul pastilelor prescrise din medicamentul respectiv, sub forma următoare:

  • substanţa activă : medicament1 preţ1, medicament2 preţ2, ..., medicamentk preţk

Din păcate, între anumite medicamente există incompatibilităţi şi ca urmare ele nu pot fi administrate simultan, deoarece ar produce reacţii adverse. De aceea, farmacista mea mi-a dat şi o listă de incompatibilităţi, în listă fiind specificate perechi de medicamente incompatibile, sub forma:

  • medicament1/medicament2

Când cumpăr reţeta, eu trebuie să iau câte un medicament pentru fiecare substanţă activă prescrisă de medic şi să am grijă să nu cumpăr medicamente care sunt incompatibile. Desigur, voi cumpăra pastilele prescrise pentru tratamentul complet.

Cunoscând lista pe care mi-a dat-o farmacista, precum şi incompatibilităţile dintre medicamente, scrieţi un program care să determine:

  1. câte medicamente am la dispoziţie pentru fiecare substanţă activă;
  2. suma minimă pe care trebuie să o cheltui pentru a cumpăra reţeta.

ONI 2016, clasa a VIII-a

Detalii

Problema Farma Operații I/O farma.in/farma.out
Limita timp 0.1 secunde Limita memorie Total: 16 MB / Stivă 8 MB
Id soluție #49110671 Utilizator mihai ungureanu (mihaileon0505)
Fișier farma.cpp Dimensiune 3.82 KB
Data încărcării 15 Februarie 2024, 15:05 Scor / rezultat Eroare de compilare

Evaluare


Mesaj compilare

farma.cpp: In function 'int solveRequirement2(std::unordered_map<std::basic_string<char>, std::vector<std::basic_string<char> > >&, std::unordered_set<std::basic_string<char> >&)':
farma.cpp:73:16: error: no match for 'operator[]' (operand types are 'std::vector<bool>' and 'std::string {aka std::basic_string<char>}')
     if (visited[node]) continue;

                ^
farma.cpp:73:16: note: candidates are:
In file included from /usr/include/c++/4.8/vector:65:0,
                 from farma.cpp:3:
/usr/include/c++/4.8/bits/stl_bvector.h:762:5: note: std::vector<bool, _Alloc>::reference std::vector<bool, _Alloc>::operator[](std::vector<bool, _Alloc>::size_type) [with _Alloc = std::allocator<bool>; std::vector<bool, _Alloc>::reference = std::_Bit_reference; std::vector<bool, _Alloc>::size_type = unsigned int]
     operator[](size_type __n)
     ^
/usr/include/c++/4.8/bits/stl_bvector.h:762:5: note:   no known conversion for argument 1 from 'std::string {aka std::basic_string<char>}' to 'std::vector<bool>::size_type {aka unsigned int}'
/usr/include/c++/4.8/bits/stl_bvector.h:769:5: note: std::vector<bool, _Alloc>::const_reference std::vector<bool, _Alloc>::operator[](std::vector<bool, _Alloc>::size_type) const [with _Alloc = std::allocator<bool>; std::vector<bool, _Alloc>::const_reference = bool; std::vector<bool, _Alloc>::size_type = unsigned int]
     operator[](size_type __n) const
     ^
/usr/include/c++/4.8/bits/stl_bvector.h:769:5: note:   no known conversion for argument 1 from 'std::string {aka std::basic_string<char>}' to 'std::vector<bool>::size_type {aka unsigned int}'
farma.cpp:74:12: error: no match for 'operator[]' (operand types are 'std::vector<bool>' and 'std::string {aka std::basic_string<char>}')
     visited[node] = true;

            ^
farma.cpp:74:12: note: candidates are:
In file included from /usr/include/c++/4.8/vector:65:0,
                 from farma.cpp:3:
/usr/include/c++/4.8/bits/stl_bvector.h:762:5: note: std::vector<bool, _Alloc>::reference std::vector<bool, _Alloc>::operator[](std::vector<bool, _Alloc>::size_type) [with _Alloc = std::allocator<bool>; std::vector<bool, _Alloc>::reference = std::_Bit_reference; std::vector<bool, _Alloc>::size_type = unsigned int]
     operator[](size_type __n)
     ^
/usr/include/c++/4.8/bits/stl_bvector.h:762:5: note:   no known conversion for argument 1 from 'std::string {aka std::basic_string<char>}' to 'std::vector<bool>::size_type {aka unsigned int}'
/usr/include/c++/4.8/bits/stl_bvector.h:769:5: note: std::vector<bool, _Alloc>::const_reference std::vector<bool, _Alloc>::operator[](std::vector<bool, _Alloc>::size_type) const [with _Alloc = std::allocator<bool>; std::vector<bool, _Alloc>::const_reference = bool; std::vector<bool, _Alloc>::size_type = unsigned int]
     operator[](size_type __n) const
     ^
/usr/include/c++/4.8/bits/stl_bvector.h:769:5: note:   no known conversion for argument 1 from 'std::string {aka std::basic_string<char>}' to 'std::vector<bool>::size_type {aka unsigned int}'
farma.cpp:76:5: error: 'total_cost' was not declared in this scope
     total_cost += cost;

     ^
farma.cpp:81:21: error: no match for 'operator[]' (operand types are 'std::vector<bool>' and 'std::string {aka std::basic_string<char>}')
         if (!visited[neighbor] && dist[neighbor] > dist[node] + weight) {

                     ^
farma.cpp:81:21: note: candidates are:
In file included from /usr/include/c++/4.8/vector:65:0,
                 from farma.cpp:3:
/usr/include/c++/4.8/bits/stl_bvector.h:762:5: note: std::vector<bool, _Alloc>::reference std::vector<bool, _Alloc>::operator[](std::vector<bool, _Alloc>::size_type) [with _Alloc = std::allocator<bool>; std::vector<bool, _Alloc>::reference = std::_Bit_reference; std::vector<bool, _Alloc>::size_type = unsigned int]
     operator[](size_type __n)
     ^
/usr/include/c++/4.8/bits/stl_bvector.h:762:5: note:   no known conversion for argument 1 from 'std::string {aka std::basic_string<char>}' to 'std::vector<bool>::size_type {aka unsigned int}'
/usr/include/c++/4.8/bits/stl_bvector.h:769:5: note: std::vector<bool, _Alloc>::const_reference std::vector<bool, _Alloc>::operator[](std::vector<bool, _Alloc>::size_type) const [with _Alloc = std::allocator<bool>; std::vector<bool, _Alloc>::const_reference = bool; std::vector<bool, _Alloc>::size_type = unsigned int]
     operator[](size_type __n) const
     ^
/usr/include/c++/4.8/bits/stl_bvector.h:769:5: note:   no known conversion for argument 1 from 'std::string {aka std::basic_string<char>}' to 'std::vector<bool>::size_type {aka unsigned int}'
farma.cpp:81:39: error: no match for 'operator[]' (operand types are 'std::vector<int>' and 'std::string {aka std::basic_string<char>}')
         if (!visited[neighbor] && dist[neighbor] > dist[node] + weight) {

                                       ^
farma.cpp:81:39: note: candidates are:
In file included from /usr/include/c++/4.8/vector:64:0,
                 from farma.cpp:3:
/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}'
farma.cpp:81:56: error: no match for 'operator[]' (operand types are 'std::vector<int>' and 'std::string {aka std::basic_string<char>}')
         if (!visited[neighbor] && dist[neighbor] > dist[node] + weight) {

                                                        ^
farma.cpp:81:56: note: candidates are:
In file included from /usr/include/c++/4.8/vector:64:0,
                 from farma.cpp:3:
/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}'
farma.cpp:82:17: error: no match for 'operator[]' (operand types are 'std::vector<int>' and 'std::string {aka std::basic_string<char>}')
             dist[neighbor] = dist[node] + weight;

                 ^
farma.cpp:82:17: note: candidates are:
In file included from /usr/include/c++/4.8/vector:64:0,
                 from farma.cpp:3:
/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}'
farma.cpp:82:34: error: no match for 'operator[]' (operand types are 'std::vector<int>' and 'std::string {aka std::basic_string<char>}')
             dist[neighbor] = dist[node] + weight;

                                  ^
farma.cpp:82:34: note: candidates are:
In file included from /usr/include/c++/4.8/vector:64:0,
                 from farma.cpp:3:
/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}'
farma.cpp:83:35: error: no match for 'operator[]' (operand types are 'std::vector<int>' and 'std::string {aka std::basic_string<char>}')
             pq.push(make_pair(dist[neighbor], neighbor));

                                   ^
farma.cpp:83:35: note: candidates are:
In file included from /usr/include/c++/4.8/vector:64:0,
                 from farma.cpp:3:
/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}'
farma.cpp:89:12: error: 'total_cost' was not declared in this scope
     return total_cost;

            ^
farma.cpp:90:1: warning: control reaches end of non-void function [-Wreturn-type]
 }

 ^

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 Farma face parte din prima categorie. Soluția propusă de tine va fi evaluată astfel:

  • Programul sursă este compilat folosind compilatorul corespunzător. Dacă în urma compilării se obțin erori sau avertismente, acestea sunt afișate în această pagină.
  • Dacă programul 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ă.