#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 | #64108700 | Utilizator | |
| Fișier | kruskal.cpp | Dimensiune | 1.48 KB |
| Data încărcării | 17 Aprilie 2026, 12:34 | Scor/rezultat | Eroare de compilare |
kruskal.cpp:6:12: warning: missing terminating " character 6 | ifstream f("kruskal.in); | ^ kruskal.cpp:6:12: error: missing terminating " character 6 | ifstream f("kruskal.in); | ^~~~~~~~~~~~~ kruskal.cpp:7:11: error: expected ‘,’ or ‘...’ before ‘(’ token 7 | ofstream g("kruskal.out"); | ^ kruskal.cpp:7:26: error: expected ‘)’ before ‘;’ token 7 | ofstream g("kruskal.out"); | ^ | ) kruskal.cpp:6:11: note: to match this ‘(’ 6 | ifstream f("kruskal.in); | ^ kruskal.cpp: In function ‘void citire(int&, int&, muchie*)’: kruskal.cpp:15:6: error: invalid operands of types ‘std::ifstream(std::ofstream)’ {aka ‘std::basic_ifstream<char>(std::basic_ofstream<char>)’} and ‘int’ to binary ‘operator>>’ 15 | f>>n>>m; | ~^~~ | | | | | int | std::ifstream(std::ofstream) {aka std::basic_ifstream<char>(std::basic_ofstream<char>)} kruskal.cpp:18:10: error: invalid operands of types ‘std::ifstream(std::ofstream)’ {aka ‘std::basic_ifstream<char>(std::basic_ofstream<char>)’} and ‘int’ to binary ‘operator>>’ 18 | f>>v[i].x>>v[i].y>>v[i].c; | ~^~~~~~~~ | | | | | int | std::ifstream(std::ofstream) {aka std::basic_ifstream<char>(std::basic_ofstream<char>)} kruskal.cpp: In function ‘void kruskal(int, int, muchie*)’: kruskal.cpp:65:9: error: ‘g’ was not declared in this scope 65 | g<<ct<<'\n'; | ^ kruskal.cpp: In function ‘int main()’: kruskal.cpp:78:7: error: request for member ‘close’ in ‘f’, which is of non-class type ‘std::ifstream(std::ofstream)’ {aka ‘std::basic_ifstream<char>(std::basic_ofstream<char>)’} 78 | f.close(); | ^~~~~ kruskal.cpp:79:5: error: ‘g’ was not declared in this scope 79 | g.close(); | ^
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ă.