Detalii evaluare #54405002

Rezumat problemă

Se dă un graf orientat ponderat – în care fiecare arc are asociat un cost, număr natural strict pozitiv, și un nod p. Să se determine, folosind algoritmul lui Dijkstra, costul minim al drumului de la p la fiecare nod al grafului.

Detalii

Problema Dijkstra Operații I/O dijkstra.in/dijkstra.out
Limita timp 0.1 secunde Limita memorie Total: 64 MB / Stivă 8 MB
Id soluție #54405002 Utilizator Necsulea Andrei (andrei_necsulea)
Fișier dijkstra.cpp Dimensiune 2.02 KB
Data încărcării 27 Noiembrie 2024, 18:15 Scor / rezultat Eroare de compilare

Evaluare


Mesaj compilare

dijkstra.cpp: In function 'void dijkstra(int)':
dijkstra.cpp:21:67: error: wrong number of template arguments (0, should be 1)
     priority_queue<pair<int, int>, vector<pair<int, int>>, greater<>> pq;

                                                                   ^
In file included from /usr/include/c++/4.8/string:48:0,
                 from /usr/include/c++/4.8/bits/locale_classes.h:40,
                 from /usr/include/c++/4.8/bits/ios_base.h:41,
                 from /usr/include/c++/4.8/ios:42,
                 from /usr/include/c++/4.8/ostream:38,
                 from /usr/include/c++/4.8/iostream:39,
                 from dijkstra.cpp:1:
/usr/include/c++/4.8/bits/stl_function.h:222:12: error: provided for 'template<class _Tp> struct std::greater'
     struct greater : public binary_function<_Tp, _Tp, bool>
            ^
dijkstra.cpp:21:68: error: template argument 3 is invalid
     priority_queue<pair<int, int>, vector<pair<int, int>>, greater<>> pq;

                                                                    ^
dijkstra.cpp:21:73: error: invalid type in declaration before ';' token
     priority_queue<pair<int, int>, vector<pair<int, int>>, greater<>> pq;

                                                                         ^
dijkstra.cpp:22:5: error: reference to 'distance' is ambiguous
     distance[source] = 0;

     ^
dijkstra.cpp:17:13: note: candidates are: std::vector<int> distance
 vector<int> distance;           // Minimum distances

             ^
In file included from /usr/include/c++/4.8/bits/stl_algobase.h:66:0,
                 from /usr/include/c++/4.8/bits/char_traits.h:39,
                 from /usr/include/c++/4.8/ios:40,
                 from /usr/include/c++/4.8/ostream:38,
                 from /usr/include/c++/4.8/iostream:39,
                 from dijkstra.cpp:1:
/usr/include/c++/4.8/bits/stl_iterator_base_funcs.h:114:5: note:                 template<class _InputIterator> typename std::iterator_traits<_Iterator>::difference_type std::distance(_InputIterator, _InputIterator)
     distance(_InputIterator __first, _InputIterator __last)
     ^
dijkstra.cpp:23:8: error: request for member 'push' in 'pq', which is of non-class type 'int'
     pq.push({0, source}); // {distance, node}

        ^
dijkstra.cpp:25:16: error: request for member 'empty' in 'pq', which is of non-class type 'int'
     while (!pq.empty()) {

                ^
dijkstra.cpp:26:23: error: request for member 'top' in 'pq', which is of non-class type 'int'
         int dist = pq.top().first;

                       ^
dijkstra.cpp:27:26: error: request for member 'top' in 'pq', which is of non-class type 'int'
         int current = pq.top().second;

                          ^
dijkstra.cpp:28:12: error: request for member 'pop' in 'pq', which is of non-class type 'int'
         pq.pop();

            ^
dijkstra.cpp:30:20: error: reference to 'distance' is ambiguous
         if (dist > distance[current]) continue; // Ignore outdated pairs in the priority queue

                    ^
dijkstra.cpp:17:13: note: candidates are: std::vector<int> distance
 vector<int> distance;           // Minimum distances

             ^
In file included from /usr/include/c++/4.8/bits/stl_algobase.h:66:0,
                 from /usr/include/c++/4.8/bits/char_traits.h:39,
                 from /usr/include/c++/4.8/ios:40,
                 from /usr/include/c++/4.8/ostream:38,
                 from /usr/include/c++/4.8/iostream:39,
                 from dijkstra.cpp:1:
/usr/include/c++/4.8/bits/stl_iterator_base_funcs.h:114:5: note:                 template<class _InputIterator> typename std::iterator_traits<_Iterator>::difference_type std::distance(_InputIterator, _InputIterator)
     distance(_InputIterator __first, _InputIterator __last)
     ^
dijkstra.cpp:36:17: error: reference to 'distance' is ambiguous
             if (distance[current] + weight < distance[next]) {

                 ^
dijkstra.cpp:17:13: note: candidates are: std::vector<int> distance
 vector<int> distance;           // Minimum distances

             ^
In file included from /usr/include/c++/4.8/bits/stl_algobase.h:66:0,
                 from /usr/include/c++/4.8/bits/char_traits.h:39,
                 from /usr/include/c++/4.8/ios:40,
                 from /usr/include/c++/4.8/ostream:38,
                 from /usr/include/c++/4.8/iostream:39,
                 from dijkstra.cpp:1:
/usr/include/c++/4.8/bits/stl_iterator_base_funcs.h:114:5: note:                 template<class _InputIterator> typename std::iterator_traits<_Iterator>::difference_type std::distance(_InputIterator, _InputIterator)
     distance(_InputIterator __first, _InputIterator __last)
     ^
dijkstra.cpp:36:46: error: reference to 'distance' is ambiguous
             if (distance[current] + weight < distance[next]) {

                                              ^
dijkstra.cpp:17:13: note: candidates are: std::vector<int> distance
 vector<int> distance;           // Minimum distances

             ^
In file included from /usr/include/c++/4.8/bits/stl_algobase.h:66:0,
                 from /usr/include/c++/4.8/bits/char_traits.h:39,
                 from /usr/include/c++/4.8/ios:40,
                 from /usr/include/c++/4.8/ostream:38,
                 from /usr/include/c++/4.8/iostream:39,
                 from dijkstra.cpp:1:
/usr/include/c++/4.8/bits/stl_iterator_base_funcs.h:114:5: note:                 template<class _InputIterator> typename std::iterator_traits<_Iterator>::difference_type std::distance(_InputIterator, _InputIterator)
     distance(_InputIterator __first, _InputIterator __last)
     ^
dijkstra.cpp:37:17: error: reference to 'distance' is ambiguous
                 distance[next] = distance[current] + weight;

                 ^
dijkstra.cpp:17:13: note: candidates are: std::vector<int> distance
 vector<int> distance;           // Minimum distances

             ^
In file included from /usr/include/c++/4.8/bits/stl_algobase.h:66:0,
                 from /usr/include/c++/4.8/bits/char_traits.h:39,
                 from /usr/include/c++/4.8/ios:40,
                 from /usr/include/c++/4.8/ostream:38,
                 from /usr/include/c++/4.8/iostream:39,
                 from dijkstra.cpp:1:
/usr/include/c++/4.8/bits/stl_iterator_base_funcs.h:114:5: note:                 template<class _InputIterator> typename std::iterator_traits<_Iterator>::difference_type std::distance(_InputIterator, _InputIterator)
     distance(_InputIterator __first, _InputIterator __last)
     ^
dijkstra.cpp:37:34: error: reference to 'distance' is ambiguous
                 distance[next] = distance[current] + weight;

                                  ^
dijkstra.cpp:17:13: note: candidates are: std::vector<int> distance
 vector<int> distance;           // Minimum distances

             ^
In file included from /usr/include/c++/4.8/bits/stl_algobase.h:66:0,
                 from /usr/include/c++/4.8/bits/char_traits.h:39,
                 from /usr/include/c++/4.8/ios:40,
                 from /usr/include/c++/4.8/ostream:38,
                 from /usr/include/c++/4.8/iostream:39,
                 from dijkstra.cpp:1:
/usr/include/c++/4.8/bits/stl_iterator_base_funcs.h:114:5: note:                 template<class _InputIterator> typename std::iterator_traits<_Iterator>::difference_type std::distance(_InputIterator, _InputIterator)
     distance(_InputIterator __first, _InputIterator __last)
     ^
dijkstra.cpp:39:20: error: request for member 'push' in 'pq', which is of non-class type 'int'
                 pq.push({distance[next], next});

                    ^
dijkstra.cpp:39:26: error: reference to 'distance' is ambiguous
                 pq.push({distance[next], next});

                          ^
dijkstra.cpp:17:13: note: candidates are: std::vector<int> distance
 vector<int> distance;           // Minimum distances

             ^
In file included from /usr/include/c++/4.8/bits/stl_algobase.h:66:0,
                 from /usr/include/c++/4.8/bits/char_traits.h:39,
                 from /usr/include/c++/4.8/ios:40,
                 from /usr/include/c++/4.8/ostream:38,
                 from /usr/include/c++/4.8/iostream:39,
                 from dijkstra.cpp:1:
/usr/include/c++/4.8/bits/stl_iterator_base_funcs.h:114:5: note:                 template<class _InputIterator> typename std::iterator_traits<_Iterator>::difference_type std::distance(_InputIterator, _InputIterator)
     distance(_InputIterator __first, _InputIterator __last)
     ^
dijkstra.cpp: In function 'int main()':
dijkstra.cpp:58:5: error: reference to 'distance' is ambiguous
     distance.assign(n + 1, INF);

     ^
dijkstra.cpp:17:13: note: candidates are: std::vector<int> distance
 vector<int> distance;           // Minimum distances

             ^
In file included from /usr/include/c++/4.8/bits/stl_algobase.h:66:0,
                 from /usr/include/c++/4.8/bits/char_traits.h:39,
                 from /usr/include/c++/4.8/ios:40,
                 from /usr/include/c++/4.8/ostream:38,
                 from /usr/include/c++/4.8/iostream:39,
                 from dijkstra.cpp:1:
/usr/include/c++/4.8/bits/stl_iterator_base_funcs.h:114:5: note:                 template<class _InputIterator> typename std::iterator_traits<_Iterator>::difference_type std::distance(_InputIterator, _InputIterator)
     distance(_InputIterator __first, _InputIterator __last)
     ^
dijkstra.cpp:70:18: error: reference to 'distance' is ambiguous
         fout << (distance[i] != INF ? distance[i] : -1) << " ";

                  ^
dijkstra.cpp:17:13: note: candidates are: std::vector<int> distance
 vector<int> distance;           // Minimum distances

             ^
In file included from /usr/include/c++/4.8/bits/stl_algobase.h:66:0,
                 from /usr/include/c++/4.8/bits/char_traits.h:39,
                 from /usr/include/c++/4.8/ios:40,
                 from /usr/include/c++/4.8/ostream:38,
                 from /usr/include/c++/4.8/iostream:39,
                 from dijkstra.cpp:1:
/usr/include/c++/4.8/bits/stl_iterator_base_funcs.h:114:5: note:                 template<class _InputIterator> typename std::iterator_traits<_Iterator>::difference_type std::distance(_InputIterator, _InputIterator)
     distance(_InputIterator __first, _InputIterator __last)
     ^
dijkstra.cpp:70:39: error: reference to 'distance' is ambiguous
         fout << (distance[i] != INF ? distance[i] : -1) << " ";

                                       ^
dijkstra.cpp:17:13: note: candidates are: std::vector<int> distance
 vector<int> distance;           // Minimum distances

             ^
In file included from /usr/include/c++/4.8/bits/stl_algobase.h:66:0,
                 from /usr/include/c++/4.8/bits/char_traits.h:39,
                 from /usr/include/c++/4.8/ios:40,
                 from /usr/include/c++/4.8/ostream:38,
                 from /usr/include/c++/4.8/iostream:39,
                 from dijkstra.cpp:1:
/usr/include/c++/4.8/bits/stl_iterator_base_funcs.h:114:5: note:                 template<class _InputIterator> typename std::iterator_traits<_Iterator>::difference_type std::distance(_InputIterator, _InputIterator)
     distance(_InputIterator __first, _InputIterator __last)
     ^

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