#588
Dijkstra
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.
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 | #54404881 | Utilizator | |
Fișier | dijkstra.cpp | Dimensiune | 2.04 KB |
Data încărcării | 27 Noiembrie 2024, 18:13 | Scor / rezultat | Eroare de compilare |
dijkstra.cpp: In function 'int main()': dijkstra.cpp:36:5: error: reference to 'distance' is ambiguous distance.assign(n + 1, INFINITY); ^ dijkstra.cpp:16:13: note: candidates are: std::vector<int> distance vector<int> distance; // Vector pentru distantele minime ^ 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:40:5: error: reference to 'distance' is ambiguous distance[source] = 0; ^ dijkstra.cpp:16:13: note: candidates are: std::vector<int> distance vector<int> distance; // Vector pentru distantele minime ^ 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:47:50: error: reference to 'distance' is ambiguous if (!visited[i] && (current == -1 || distance[i] < distance[current])) { ^ dijkstra.cpp:16:13: note: candidates are: std::vector<int> distance vector<int> distance; // Vector pentru distantele minime ^ 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:47:64: error: reference to 'distance' is ambiguous if (!visited[i] && (current == -1 || distance[i] < distance[current])) { ^ dijkstra.cpp:16:13: note: candidates are: std::vector<int> distance vector<int> distance; // Vector pentru distantele minime ^ 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:58:61: error: reference to 'distance' is ambiguous if (!visited[i] && a[current][i] != INFINITY && distance[current] + a[current][i] < distance[i]) { ^ dijkstra.cpp:16:13: note: candidates are: std::vector<int> distance vector<int> distance; // Vector pentru distantele minime ^ 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:58:97: error: reference to 'distance' is ambiguous if (!visited[i] && a[current][i] != INFINITY && distance[current] + a[current][i] < distance[i]) { ^ dijkstra.cpp:16:13: note: candidates are: std::vector<int> distance vector<int> distance; // Vector pentru distantele minime ^ 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:59:17: error: reference to 'distance' is ambiguous distance[i] = distance[current] + a[current][i]; ^ dijkstra.cpp:16:13: note: candidates are: std::vector<int> distance vector<int> distance; // Vector pentru distantele minime ^ 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:59:31: error: reference to 'distance' is ambiguous distance[i] = distance[current] + a[current][i]; ^ dijkstra.cpp:16:13: note: candidates are: std::vector<int> distance vector<int> distance; // Vector pentru distantele minime ^ 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:67:18: error: reference to 'distance' is ambiguous fout << (distance[i] != INFINITY ? distance[i] : -1) << " "; ^ dijkstra.cpp:16:13: note: candidates are: std::vector<int> distance vector<int> distance; // Vector pentru distantele minime ^ 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:67:44: error: reference to 'distance' is ambiguous fout << (distance[i] != INFINITY ? distance[i] : -1) << " "; ^ dijkstra.cpp:16:13: note: candidates are: std::vector<int> distance vector<int> distance; // Vector pentru distantele minime ^ 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) ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema Dijkstra face parte din prima categorie. 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ă.