#4950
Fie G un graf neorientat conex cu N noduri și M muchii. Nodurile sunt numerotate de la 1 la N iar muchiile au asociate costuri numere naturale date. Un graf parţial al lui G conex şi fără cicluri este denumit arbore parţial. Costul unui arbore parțial este suma costurilor muchiilor arborelui. Deoarece unele muchii pot avea aceelași cost, este posibil ca graful G să aibă mai mulți arbori parțiali de cost minim. Definim o muchie a grafului G ca fiind esențială dacă ea face parte din toți arborii parțiali de cost minim ai lui G. Scrieţi un program care, cunoscând graful, rezolvă următoarele două cerinţe:
1. determină costul unui arbore parțial de cost minim al lui G;
2. determină numărul de muchii esențiale ale grafului G.
OMI 2026, clasele 11-12
| Problema | esentiale | Operații I/O |
esentiale.in/esentiale.out
|
|---|---|---|---|
| Limita timp | 0.5 secunde | Limita memorie |
Total: 64 MB
/
Stivă 16 MB
|
| Id soluție | #64118708 | Utilizator | |
| Fișier | esentiale.cpp | Dimensiune | 1.82 KB |
| Data încărcării | 18 Aprilie 2026, 11:21 | Scor/rezultat | 100 puncte |
esentiale.cpp: In function ‘std::pair<long long int, std::vector<int> > kruskal()’: esentiale.cpp:44:21: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::vector<std::tuple<int, int, int, bool> >::size_type’ {aka ‘long unsigned int’} [-Wsign-compare] 44 | for(int i = 0; i<edges.size(); i++){ | ~^~~~~~~~~~~~~ esentiale.cpp:45:14: warning: structured bindings only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions] 45 | auto [c,x,y,skip] = edges[i]; | ^ esentiale.cpp:54:23: warning: comparison of integer expressions of different signedness: ‘std::vector<int>::size_type’ {aka ‘long unsigned int’} and ‘long long int’ [-Wsign-compare] 54 | if(apm.size() == n-1) break; | ~~~~~~~~~~~^~~~~~ esentiale.cpp: In function ‘int main()’: esentiale.cpp:62:10: warning: structured bindings only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions] 62 | auto [cost_min, apm_idx] = kruskal(); | ^ esentiale.cpp:71:40: warning: comparison of integer expressions of different signedness: ‘std::vector<int>::size_type’ {aka ‘long unsigned int’} and ‘long long int’ [-Wsign-compare] 71 | if(kruskal().second.size() < n-1 || kruskal().first > cost_min) cnt++; | ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
| Test | Timp | Mesaj evaluare | Scor posibil | Scor obținut | ||
|---|---|---|---|---|---|---|
| 0 | 0.001 secunde | OK. | 4 | 4 | ||
| 1 | 0.001 secunde | OK. | 5 | 5 | ||
| 2 | 0.001 secunde | OK. | 6 | 6 | ||
| 3 | 0.001 secunde | OK. | 5 | 5 | ||
| 4 | 0.001 secunde | OK. | 6 | 6 | ||
| 5 | 0.001 secunde | OK. | 8 | 8 | ||
| 6 | 0.002 secunde | OK. | 7 | 7 | ||
| 7 | 0.004 secunde | OK. | 6 | 6 | ||
| 8 | 0.001 secunde | OK. | 7 | 7 | ||
| 9 | 0.027 secunde | OK. | 7 | 7 | ||
| 10 | 0.044 secunde | OK. | 8 | 8 | ||
| 11 | 0.012 secunde | OK. | 3 | 3 | ||
| 12 | 0.053 secunde | OK. | 4 | 4 | ||
| 13 | 0.073 secunde | OK. | 8 | 8 | ||
| 14 | 0.028 secunde | OK. | 6 | 6 | ||
| 15 | 0.001 secunde | OK. | 5 | 5 | Exemplu | |
| 16 | 0.001 secunde | OK. | 5 | 5 | Exemplu | |
| Punctaj total | 100 | |||||
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema esentiale 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ă.