#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 | #64109170 | Utilizator | |
| Fișier | kruskal.cpp | Dimensiune | 1.06 KB |
| Data încărcării | 17 Aprilie 2026, 12:46 | Scor/rezultat | Eroare de compilare |
kruskal.cpp: In function ‘void citire(int)’: kruskal.cpp:13:12: error: ‘v’ was not declared in this scope 13 | f>>v[i].x>>v[i].y>>v[i].c; | ^ kruskal.cpp: In function ‘void sortare()’: kruskal.cpp:19:12: error: ‘v’ was not declared in this scope 19 | if(v[i].c>v[j].c) | ^ kruskal.cpp:21:9: error: ‘aux’ was not declared in this scope 21 | aux=v[i]; | ^~~ kruskal.cpp: At global scope: kruskal.cpp:26:27: error: ‘elem’ has not been declared 26 | void kruskal(int n,int m, elem v[]) | ^~~~ kruskal.cpp: In function ‘void kruskal(int, int, int*)’: kruskal.cpp:30:5: error: ‘sorty’ was not declared in this scope 30 | sorty(m,v); | ^~~~~ kruskal.cpp:34:19: error: request for member ‘x’ in ‘*(v + ((sizetype)(((long unsigned int)i) * 4)))’, which is of non-class type ‘int’ 34 | if(l[v[i].x]!=l[v[i].y]) | ^ kruskal.cpp:34:30: error: request for member ‘y’ in ‘*(v + ((sizetype)(((long unsigned int)i) * 4)))’, which is of non-class type ‘int’ 34 | if(l[v[i].x]!=l[v[i].y]) | ^ kruskal.cpp:38:22: error: request for member ‘c’ in ‘*(v + ((sizetype)(((long unsigned int)i) * 4)))’, which is of non-class type ‘int’ 38 | ct+=v[i].c; | ^ kruskal.cpp:39:24: error: request for member ‘x’ in ‘*(v + ((sizetype)(((long unsigned int)i) * 4)))’, which is of non-class type ‘int’ 39 | nr1=l[v[i].x]; | ^ kruskal.cpp:41:24: error: request for member ‘y’ in ‘*(v + ((sizetype)(((long unsigned int)i) * 4)))’, which is of non-class type ‘int’ 41 | nr2=l[v[i].y]; | ^ kruskal.cpp:42:12: error: ‘vect’ was not declared in this scope; did you mean ‘ct’? 42 | vect[k].x=v[i].x; | ^~~~ | ct kruskal.cpp:42:27: error: request for member ‘x’ in ‘*(v + ((sizetype)(((long unsigned int)i) * 4)))’, which is of non-class type ‘int’ 42 | vect[k].x=v[i].x; | ^ kruskal.cpp:43:27: error: request for member ‘y’ in ‘*(v + ((sizetype)(((long unsigned int)i) * 4)))’, which is of non-class type ‘int’ 43 | vect[k].y=v[i].y; | ^ kruskal.cpp:28:13: warning: unused variable ‘j’ [-Wunused-variable] 28 | int i=1,j,k=0,l[1009],nr1,nr2; | ^ kruskal.cpp: In function ‘int main()’: kruskal.cpp:55:16: error: ‘v’ was not declared in this scope 55 | citire(n,m,v) | ^ kruskal.cpp:54:9: warning: unused variable ‘x’ [-Wunused-variable] 54 | int x,y; | ^ kruskal.cpp:54:11: warning: unused variable ‘y’ [-Wunused-variable] 54 | int x,y; | ^
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ă.