#592
Kruskal
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 | #50992225 | Utilizator | |
Fișier | kruskal.cpp | Dimensiune | 737 B |
Data încărcării | 17 Mai 2024, 14:32 | Scor / rezultat | Eroare de compilare |
kruskal.cpp: In function 'int main()': kruskal.cpp:6:24: error: expected ';' at end of member declaration { struct muchie{int i, j cost} ^ kruskal.cpp:6:26: error: 'cost' does not name a type { struct muchie{int i, j cost} ^ kruskal.cpp:6:30: error: expected ';' after struct definition { struct muchie{int i, j cost} ^ kruskal.cpp:7:52: error: expected initializer before 'aj' int n, m, t[105], v[120], x[120],S=0, cnt=0, ai aj, aux[120]; ^ kruskal.cpp:9:8: error: expected '(' before 'i' for i=1,i<=m;i++) ^ kruskal.cpp:9:8: error: 'i' was not declared in this scope kruskal.cpp:9:20: error: expected ';' before ')' token for i=1,i<=m;i++) ^ kruskal.cpp:12:8: error: 'i' was not declared in this scope for(i=0,i<m-1;i++;) ^ kruskal.cpp:13:9: error: 'j' was not declared in this scope for(j=1;j<m;j++) ^ kruskal.cpp:16:6: error: 'aux' was not declared in this scope { aux=x[i]; ^ kruskal.cpp:20:8: error: 'i' was not declared in this scope for(i=1;i<=n;i++) ^ kruskal.cpp:22:8: error: 'i' was not declared in this scope for(i=0;i<m&&cnt<n,i++) ^ kruskal.cpp:22:26: error: expected ';' before ')' token for(i=0;i<m&&cnt<n,i++) ^ kruskal.cpp:23:20: error: expected ',' before '[' token if(t[x[i].i]!=[x[i].j]) ^ kruskal.cpp:23:20: error: expected identifier before '[' token kruskal.cpp: In lambda function: kruskal.cpp:23:26: error: expected '{' before ')' token if(t[x[i].i]!=[x[i].j]) ^ kruskal.cpp: In function 'int main()': kruskal.cpp:28:8: error: 'ai' was not declared in this scope ai=t[x[i].i]; ^ kruskal.cpp:29:8: error: 'aj' was not declared in this scope aj=t[x[i].j]; ^ kruskal.cpp:30:12: error: 'j' was not declared in this scope for(j=1;j<=n,j++) ^ kruskal.cpp:30:24: error: expected ';' before ')' token for(j=1;j<=n,j++) ^ kruskal.cpp:34:4: error: expected unqualified-id before '}' token } ^ kruskal.cpp:34:4: error: expected ';' before '}' token kruskal.cpp:36:11: error: 'i' was not declared in this scope for(i=0;i<m;i++) ^
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ă.