Detalii evaluare #29066137

Rezumat problemă

#590 Prim

Se dă un graf neorientat ponderat conex cu n vârfuri și m muchii – în care fiecare muchie are asociat un cost, număr natural strict pozitiv. Folosind algoritmul lui Prim, determinați un arbore parțial de cost minim, cu rădăcina în vârful 1.

Detalii

Problema Prim Operații I/O prim.in/prim.out
Limita timp 0.1 secunde Limita memorie Total: 64 MB / Stivă 8 MB
Id soluție #29066137 Utilizator Vasile Andrei (AndreiVas20)
Fișier prim.cpp Dimensiune 2.38 KB
Data încărcării 29 Martie 2021, 23:17 Scor / rezultat Eroare de compilare

Evaluare


Mesaj compilare

prim.cpp:57:1: error: expected unqualified-id before '[' token
 [11:16 PM]

 ^
prim.cpp:63:13: error: redefinition of 'std::ifstream cin'
 ifstream cin("prim.in");

             ^
prim.cpp:7:10: error: 'std::ifstream cin' previously declared here
 ifstream cin("mere.in");

          ^
prim.cpp:64:14: error: redefinition of 'std::ofstream cout'
 ofstream cout("prim.out");

              ^
prim.cpp:8:10: error: 'std::ofstream cout' previously declared here
 ofstream cout("mere.out");

          ^
prim.cpp:66:31: error: conflicting declaration 'std::vector<std::pair<int, int> > G [101]'
 vector <pair<int , int>> G[101];

                               ^
prim.cpp:11:14: error: 'G' has a previous declaration as 'std::vector<int> G [1001]'
 vector <int> G[1001];

              ^
prim.cpp:68:5: error: redefinition of 'int n'
 int n , m , x , y , c , S;

     ^
prim.cpp:10:5: error: 'int n' previously declared here
 int n , x , y , m[1001] , p , d[1001] , v[1001] , sum , maxi , imax;

     ^
prim.cpp:68:9: error: conflicting declaration 'int m'
 int n , m , x , y , c , S;

         ^
prim.cpp:10:17: error: 'm' has a previous declaration as 'int m [1001]'
 int n , x , y , m[1001] , p , d[1001] , v[1001] , sum , maxi , imax;

                 ^
prim.cpp:68:13: error: redefinition of 'int x'
 int n , m , x , y , c , S;

             ^
prim.cpp:10:9: error: 'int x' previously declared here
 int n , x , y , m[1001] , p , d[1001] , v[1001] , sum , maxi , imax;

         ^
prim.cpp:68:17: error: redefinition of 'int y'
 int n , m , x , y , c , S;

                 ^
prim.cpp:10:13: error: 'int y' previously declared here
 int n , x , y , m[1001] , p , d[1001] , v[1001] , sum , maxi , imax;

             ^
prim.cpp: In function 'int main()':
prim.cpp:72:5: error: redefinition of 'int main()'
 int main()

     ^
prim.cpp:41:5: error: 'int main()' previously defined here
 int main()

     ^
prim.cpp:74:13: error: cannot bind 'std::basic_istream<char>::__istream_type {aka std::basic_istream<char>}' lvalue to 'std::basic_istream<char>&&'
     for(cin >> n >> m ; m ; --m)

             ^
In file included from /usr/include/c++/4.8/fstream:38:0,
                 from prim.cpp:1:
/usr/include/c++/4.8/istream:872:5: error:   initializing argument 1 of 'std::basic_istream<_CharT, _Traits>& std::operator>>(std::basic_istream<_CharT, _Traits>&&, _Tp&) [with _CharT = char; _Traits = std::char_traits<char>; _Tp = int [1001]]'
     operator>>(basic_istream<_CharT, _Traits>&& __is, _Tp& __x)
     ^
prim.cpp:74:25: warning: the address of 'm' will always evaluate as 'true' [-Waddress]
     for(cin >> n >> m ; m ; --m)

                         ^
prim.cpp:74:31: error: lvalue required as decrement operand
     for(cin >> n >> m ; m ; --m)

                               ^
prim.cpp:77:31: error: no matching function for call to 'std::vector<int>::push_back(<brace-enclosed initializer list>)'
         G[x].push_back({c , y});

                               ^
prim.cpp:77:31: note: candidates are:
In file included from /usr/include/c++/4.8/vector:64:0,
                 from prim.cpp:2:
/usr/include/c++/4.8/bits/stl_vector.h:901:7: note: void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::value_type = int]
       push_back(const value_type& __x)
       ^
/usr/include/c++/4.8/bits/stl_vector.h:901:7: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type& {aka const int&}'
/usr/include/c++/4.8/bits/stl_vector.h:919:7: note: void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::value_type = int]
       push_back(value_type&& __x)
       ^
/usr/include/c++/4.8/bits/stl_vector.h:919:7: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<int>::value_type&& {aka int&&}'
prim.cpp:78:31: error: no matching function for call to 'std::vector<int>::push_back(<brace-enclosed initializer list>)'
         G[y].push_back({c , x});

                               ^
prim.cpp:78:31: note: candidates are:
In file included from /usr/include/c++/4.8/vector:64:0,
                 from prim.cpp:2:
/usr/include/c++/4.8/bits/stl_vector.h:901:7: note: void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::value_type = int]
       push_back(const value_type& __x)
       ^
/usr/include/c++/4.8/bits/stl_vector.h:901:7: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type& {aka const int&}'
/usr/include/c++/4.8/bits/stl_vector.h:919:7: note: void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::value_type = int]
       push_back(value_type&& __x)
       ^
/usr/include/c++/4.8/bits/stl_vector.h:919:7: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<int>::value_type&& {aka int&&}'
prim.cpp:97:13: error: request for member 'second' in 'x', which is of non-class type 'int'
         T[x.second] = 1;

             ^
prim.cpp:98:13: error: request for member 'second' in 'x', which is of non-class type 'int'
         D[x.second] = x.first;

             ^
prim.cpp:98:25: error: request for member 'first' in 'x', which is of non-class type 'int'
         D[x.second] = x.first;

                         ^
prim.cpp:99:17: error: no matching function for call to 'std::priority_queue<std::pair<int, int>, std::vector<std::pair<int, int> >, std::greater<std::pair<int, int> > >::push(int&)'
         Q.push(x);

                 ^
prim.cpp:99:17: note: candidates are:
In file included from /usr/include/c++/4.8/queue:64:0,
                 from prim.cpp:4:
/usr/include/c++/4.8/bits/stl_queue.h:496:7: note: void std::priority_queue<_Tp, _Sequence, _Compare>::push(const value_type&) [with _Tp = std::pair<int, int>; _Sequence = std::vector<std::pair<int, int> >; _Compare = std::greater<std::pair<int, int> >; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = std::pair<int, int>]
       push(const value_type& __x)
       ^
/usr/include/c++/4.8/bits/stl_queue.h:496:7: note:   no known conversion for argument 1 from 'int' to 'const value_type& {aka const std::pair<int, int>&}'
/usr/include/c++/4.8/bits/stl_queue.h:504:7: note: void std::priority_queue<_Tp, _Sequence, _Compare>::push(std::priority_queue<_Tp, _Sequence, _Compare>::value_type&&) [with _Tp = std::pair<int, int>; _Sequence = std::vector<std::pair<int, int> >; _Compare = std::greater<std::pair<int, int> >; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = std::pair<int, int>]
       push(value_type&& __x)
       ^
/usr/include/c++/4.8/bits/stl_queue.h:504:7: note:   no known conversion for argument 1 from 'int' to 'std::priority_queue<std::pair<int, int>, std::vector<std::pair<int, int> >, std::greater<std::pair<int, int> > >::value_type&& {aka std::pair<int, int>&&}'
prim.cpp:114:20: error: request for member 'second' in 'x', which is of non-class type 'int'
             if(V[x.second] == false && D[x.second] > x.first)

                    ^
prim.cpp:114:44: error: request for member 'second' in 'x', which is of non-class type 'int'
             if(V[x.second] == false && D[x.second] > x.first)

                                            ^
prim.cpp:114:56: error: request for member 'first' in 'x', which is of non-class type 'int'
             if(V[x.second] == false && D[x.second] > x.first)

                                                        ^
prim.cpp:116:21: error: request for member 'second' in 'x', which is of non-class type 'int'
                 T[x.second] = P.second;

                     ^
prim.cpp:117:21: error: request for member 'second' in 'x', which is of non-class type 'int'
                 D[x.second] = x.first;

                     ^
prim.cpp:117:33: error: request for member 'first' in 'x', which is of non-class type 'int'
                 D[x.second] = x.first;

                                 ^
prim.cpp:118:25: error: no matching function for call to 'std::priority_queue<std::pair<int, int>, std::vector<std::pair<int, int> >, std::greater<std::pair<int, int> > >::push(int&)'
                 Q.push(x);

                         ^
prim.cpp:118:25: note: candidates are:
In file included from /usr/include/c++/4.8/queue:64:0,
                 from prim.cpp:4:
/usr/include/c++/4.8/bits/stl_queue.h:496:7: note: void std::priority_queue<_Tp, _Sequence, _Compare>::push(const value_type&) [with _Tp = std::pair<int, int>; _Sequence = std::vector<std::pair<int, int> >; _Compare = std::greater<std::pair<int, int> >; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = std::pair<int, int>]
       push(const value_type& __x)
       ^
/usr/include/c++/4.8/bits/stl_queue.h:496:7: note:   no known conversion for argument 1 from 'int' to 'const value_type& {aka const std::pair<int, int>&}'
/usr/include/c++/4.8/bits/stl_queue.h:504:7: note: void std::priority_queue<_Tp, _Sequence, _Compare>::push(std::priority_queue<_Tp, _Sequence, _Compare>::value_type&&) [with _Tp = std::pair<int, int>; _Sequence = std::vector<std::pair<int, int> >; _Compare = std::greater<std::pair<int, int> >; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = std::pair<int, int>]
       push(value_type&& __x)
       ^
/usr/include/c++/4.8/bits/stl_queue.h:504:7: note:   no known conversion for argument 1 from 'int' to 'std::priority_queue<std::pair<int, int>, std::vector<std::pair<int, int> >, std::greater<std::pair<int, int> > >::value_type&& {aka std::pair<int, int>&&}'

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