#645
Se dă vectorul de tați al unui arbore cu rădăcină cu n noduri în care fiecare nod are asociată o valoare numerică. Determinați drumul de la rădăcină la un nod terminal pentru care suma valorilor asociate nodurilor este maximă.
| Problema | DetDrum3 | Operații I/O |
detdrum3.in/detdrum3.out
|
|---|---|---|---|
| Limita timp | 0.1 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
| Id soluție | #64185794 | Utilizator | |
| Fișier | detdrum3.cpp | Dimensiune | 708 B |
| Data încărcării | 22 Aprilie 2026, 08:47 | Scor/rezultat | Eroare de compilare |
detdrum3.cpp:5:1: error: expected ‘,’ or ‘;’ before ‘int’ 5 | int v[101],c[101],n,cmax,t[101]; | ^~~ detdrum3.cpp: In function ‘int cost(int)’: detdrum3.cpp:8:8: error: ‘t’ was not declared in this scope 8 | if(t[x]==0) | ^ detdrum3.cpp:9:16: error: ‘v’ was not declared in this scope 9 | return v[x]; | ^ detdrum3.cpp:11:16: error: ‘v’ was not declared in this scope 11 | return v[x]+cost(t[x]); | ^ detdrum3.cpp: In function ‘void drum(int)’: detdrum3.cpp:16:8: error: ‘t’ was not declared in this scope 16 | if(t[x]!=0) | ^ detdrum3.cpp: In function ‘int main()’: detdrum3.cpp:22:8: error: ‘n’ was not declared in this scope 22 | cin>>n; | ^ detdrum3.cpp:24:10: error: ‘t’ was not declared in this scope 24 | cin>>t[i]; | ^ detdrum3.cpp:26:5: error: ‘v’ was not declared in this scope 26 | v[i]; | ^ detdrum3.cpp:28:8: error: ‘c’ was not declared in this scope 28 | {c[i]=cost(i); | ^ detdrum3.cpp:29:16: error: ‘cmax’ was not declared in this scope 29 | if(c[i]>cmax) | ^~~~ detdrum3.cpp:32:11: error: ‘cmax’ was not declared in this scope 32 | cout<<cmax<<endl; | ^~~~ detdrum3.cpp:33:10: error: expected unqualified-id before ‘=’ token 33 | for(int=1; i<=n;i++) | ^ detdrum3.cpp:33:10: error: expected ‘;’ before ‘=’ token 33 | for(int=1; i<=n;i++) | ^ | ; detdrum3.cpp:33:10: error: expected primary-expression before ‘=’ token detdrum3.cpp:33:14: error: ‘i’ was not declared in this scope 33 | for(int=1; i<=n;i++) | ^ detdrum3.cpp:33:18: error: expected ‘)’ before ‘;’ token 33 | for(int=1; i<=n;i++) | ~ ^ | ) detdrum3.cpp:33:3: warning: this ‘for’ clause does not guard... [-Wmisleading-indentation] 33 | for(int=1; i<=n;i++) | ^~~ detdrum3.cpp:33:19: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘for’ 33 | for(int=1; i<=n;i++) | ^ detdrum3.cpp:33:19: error: ‘i’ was not declared in this scope
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema DetDrum3 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ă.