#592
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 Kruskal, determinați un arbore parțial de cost minim.
| Problema | Kruskal | Operații I/O |
kruskal.in/kruskal.out
|
|---|---|---|---|
| Limita timp | 0.1 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
| Id soluție | #64467122 | Utilizator | |
| Fișier | kruskal.cpp | Dimensiune | 1.37 KB |
| Data încărcării | 08 Mai 2026, 13:25 | Scor/rezultat | Eroare de compilare |
kruskal.cpp:5:12: warning: character constant too long for its type 5 | ifstream f('kruskal.in') | ^~~~~~~~~~~~ kruskal.cpp:6:12: warning: character constant too long for its type 6 | ofstream g('kruskal.out') | ^~~~~~~~~~~~~ kruskal.cpp:5:12: error: invalid conversion from ‘int’ to ‘const char*’ [-fpermissive] 5 | ifstream f('kruskal.in') | ^~~~~~~~~~~~ | | | int In file included from kruskal.cpp:3: /usr/include/c++/13/fstream:536:34: note: initializing argument 1 of ‘std::basic_ifstream<_CharT, _Traits>::basic_ifstream(const char*, std::ios_base::openmode) [with _CharT = char; _Traits = std::char_traits<char>; std::ios_base::openmode = std::ios_base::openmode]’ 536 | basic_ifstream(const char* __s, ios_base::openmode __mode = ios_base::in) | ~~~~~~~~~~~~^~~ kruskal.cpp:6:1: error: expected ‘,’ or ‘;’ before ‘ofstream’ 6 | ofstream g('kruskal.out') | ^~~~~~~~ kruskal.cpp:10:3: error: ‘v’ does not name a type 10 | } v[101] , aux; | ^ kruskal.cpp: In function ‘int main()’: kruskal.cpp:16:12: error: ‘v’ was not declared in this scope 16 | f>>v[i].x>>v[i].y>>v[i].c; | ^ kruskal.cpp:19:16: error: ‘v’ was not declared in this scope 19 | if(v[i].c>v[j].c) | ^ kruskal.cpp:21:17: error: ‘aux’ was not declared in this scope 21 | aux=v[i]; | ^~~ kruskal.cpp:18:9: warning: this ‘for’ clause does not guard... [-Wmisleading-indentation] 18 | for(j=i+1;j<=m;j++) | ^~~ kruskal.cpp:25:13: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘for’ 25 | for(i=1;i<=n;i++) | ^~~ kruskal.cpp:31:19: error: ‘v’ was not declared in this scope 31 | x=v[i].x; | ^ kruskal.cpp:36:21: error: ‘g’ was not declared in this scope 36 | g<<x<<" "<<y<<endl; | ^ kruskal.cpp:58:13: error: ‘g’ was not declared in this scope 58 | g<<cost<<endl; | ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema Kruskal 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ă.